13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 2.0 Module 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * ------------------------------------------------- 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project 63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License"); 83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License. 93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at 103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * http://www.apache.org/licenses/LICENSE-2.0 123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software 143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS, 153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and 173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License. 183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*! 203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file 213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Clipping tests. 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es2fClippingTests.hpp" 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuRenderTarget.hpp" 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTextureUtil.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuImageCompare.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuVectorUtil.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deStringUtil.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp" 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "sglrReferenceContext.hpp" 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "sglrGLContext.hpp" 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp" 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwDefs.hpp" 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwFunctions.hpp" 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace glw; // GLint and other GL types 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles2 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::PixelBufferAccess; 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::ConstPixelBufferAccess; 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog; 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const tcu::Vec4 MASK_COLOR_OK = tcu::Vec4(0.0f, 0.1f, 0.0f, 1.0f); 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const tcu::Vec4 MASK_COLOR_DEV = tcu::Vec4(0.8f, 0.5f, 0.0f, 1.0f); 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const tcu::Vec4 MASK_COLOR_FAIL = tcu::Vec4(1.0f, 0.0f, 1.0f, 1.0f); 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryconst int TEST_CANVAS_SIZE = 200; 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyryconst rr::WindowRectangle VIEWPORT_WHOLE (0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE); 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyryconst rr::WindowRectangle VIEWPORT_CENTER (TEST_CANVAS_SIZE/4, TEST_CANVAS_SIZE/4, TEST_CANVAS_SIZE/2, TEST_CANVAS_SIZE/2); 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyryconst rr::WindowRectangle VIEWPORT_CORNER (TEST_CANVAS_SIZE/2, TEST_CANVAS_SIZE/2, TEST_CANVAS_SIZE/2, TEST_CANVAS_SIZE/2); 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyryconst char* shaderSourceVertex = "attribute highp vec4 a_position;\n" 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "attribute highp vec4 a_color;\n" 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "attribute highp float a_pointSize;\n" 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "varying mediump vec4 varFragColor;\n" 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "void main (void)\n" 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "{\n" 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " gl_Position = a_position;\n" 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " gl_PointSize = a_pointSize;\n" 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " varFragColor = a_color;\n" 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "}\n"; 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyryconst char* shaderSourceFragment = "varying mediump vec4 varFragColor;\n" 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "void main (void)\n" 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "{\n" 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " gl_FragColor = varFragColor;\n" 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "}\n"; 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline bool isBlack (const tcu::IVec4& a) 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return a.x() == 0 && a.y() == 0 && a.z() == 0; 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline bool isHalfFilled (const tcu::IVec4& a) 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::IVec4 halfFilled (127, 0, 0, 0); 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::IVec4 threshold (20, 256, 256, 256); 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return tcu::boolAll(tcu::lessThanEqual(tcu::abs(a - halfFilled), threshold)); 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline bool isLessThanHalfFilled (const tcu::IVec4& a) 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int halfFilled = 127; 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int threshold = 20; 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return a.x() + threshold < halfFilled; 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline bool compareBlackNonBlackPixels (const tcu::IVec4& a, const tcu::IVec4& b) 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return isBlack(a) == isBlack(b); 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline bool compareColoredPixels (const tcu::IVec4& a, const tcu::IVec4& b) 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool aIsBlack = isBlack(a); 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool bIsBlack = isBlack(b); 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::IVec4 threshold(20, 20, 20, 0); 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (aIsBlack && bIsBlack) 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return true; 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (aIsBlack != bIsBlack) 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return tcu::boolAll(tcu::lessThanEqual(tcu::abs(a - b), threshold)); 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid blitImageOnBlackSurface(const ConstPixelBufferAccess& src, const PixelBufferAccess& dst) 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int height = src.getHeight(); 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int width = src.getWidth(); 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int y = 0; y < height; y++) 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int x = 0; x < width; x++) 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::IVec4 cSrc = src.getPixelInt(x, y); 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::IVec4 cDst = tcu::IVec4(cSrc.x(), cSrc.y(), cSrc.z(), 255); 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.setPixel(cDst, x, y); 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Pixelwise comparison of two images. 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \note copied & modified from glsRasterizationTests 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Kernel radius defines maximum allowed distance. If radius is 0, only 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * perfect match is allowed. Radius of 1 gives a 3x3 kernel. Pixels are 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * equal if pixelCmp returns true.. 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Return values: -1 = Perfect match 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 0 = Deviation within kernel 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * >0 = Number of faulty pixels 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline 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)) 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int height = test.getHeight(); 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int width = test.getWidth(); 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int deviatingPixels = 0; 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int faultyPixels = 0; 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int compareFailed = -1; 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::clear(diffMask, MASK_COLOR_OK); 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int y = 0; y < height; y++) 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int x = 0; x < width; x++) 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::IVec4 cRef = ref.getPixelInt(x, y); 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::IVec4 cTest = test.getPixelInt(x, y); 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Pixelwise match, no deviation or fault 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((*pixelCmp)(cRef, cTest)) 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Deviation 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int radius = kernelRadius; 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool foundRef = false; 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool foundTest = false; 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // edges are considered a "deviation" too. The suitable pixel could be "behind" the edge 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (y < radius || x < radius || y + radius >= height || x + radius >= width) 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry foundRef = true; 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry foundTest = true; 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // find ref 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int kY = y - radius; kY <= y + radius; kY++) 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int kX = x - radius; kX <= x + radius; kX++) 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((*pixelCmp)(cRef, test.getPixelInt(kX, kY))) 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry foundRef = true; 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // find result 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int kY = y - radius; kY <= y + radius; kY++) 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int kX = x - radius; kX <= x + radius; kX++) 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((*pixelCmp)(cTest, ref.getPixelInt(kX, kY))) 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry foundTest = true; 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // 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) 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // the result color is found in the reference image inside the kernel (~= every pixel gl draws must be drawn by the reference too) 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (foundRef && foundTest) 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry diffMask.setPixel(MASK_COLOR_DEV, x, y); 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (compareFailed == -1) 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry compareFailed = 0; 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deviatingPixels++; 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry diffMask.setPixel(MASK_COLOR_FAIL, x, y); 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry faultyPixels++; // The pixel is faulty if the color is not found 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry compareFailed = 1; 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << deviatingPixels << " deviating pixel(s) found." << TestLog::EndMessage; 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << faultyPixels << " faulty pixel(s) found." << TestLog::EndMessage; 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return (compareFailed == 1 ? faultyPixels : compareFailed); 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Pixelwise comparison of two images. 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Kernel radius defines maximum allowed distance. If radius is 0, only 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * perfect match is allowed. Radius of 1 gives a 3x3 kernel. Pixels are 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * equal if they both are black, or both are non-black. 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Return values: -1 = Perfect match 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 0 = Deviation within kernel 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * >0 = Number of faulty pixels 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint compareBlackNonBlackImages (tcu::TestLog& log, const ConstPixelBufferAccess& test, const ConstPixelBufferAccess& ref, const PixelBufferAccess& diffMask, int kernelRadius) 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return compareImages(log, test, ref, diffMask, kernelRadius, compareBlackNonBlackPixels); 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Pixelwise comparison of two images. 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Kernel radius defines maximum allowed distance. If radius is 0, only 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * perfect match is allowed. Radius of 1 gives a 3x3 kernel. Pixels are 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * equal if they both are black, or both are non-black with color values 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * close to each other. 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Return values: -1 = Perfect match 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 0 = Deviation within kernel 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * >0 = Number of faulty pixels 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint compareColoredImages (tcu::TestLog& log, const ConstPixelBufferAccess& test, const ConstPixelBufferAccess& ref, const PixelBufferAccess& diffMask, int kernelRadius) 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return compareImages(log, test, ref, diffMask, kernelRadius, compareColoredPixels); 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Overdraw check verification 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Check that image does not have at any point a 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * pixel with red component value > 0.5 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Return values: false = area not filled, or leaking 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool checkHalfFilledImageOverdraw (tcu::TestLog& log, const tcu::RenderTarget& m_renderTarget, const ConstPixelBufferAccess& image, const PixelBufferAccess& output) 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int height = image.getHeight(); 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int width = image.getWidth(); 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool faulty = false; 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::clear(output, MASK_COLOR_OK); 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int y = 0; y < height; y++) 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int x = 0; x < width; x++) 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::IVec4 cTest = image.getPixelInt(x, y); 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool pixelValid = isBlack(cTest) || isHalfFilled(cTest) || (m_renderTarget.getNumSamples() > 1 && isLessThanHalfFilled(cTest)); 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!pixelValid) 2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry output.setPixel(MASK_COLOR_FAIL, x, y); 2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry faulty = true; 2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (faulty) 2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Faulty pixel(s) found." << TestLog::EndMessage; 2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return !faulty; 2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid checkPointSize (const glw::Functions& gl, float pointSize) 3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLfloat pointSizeRange[2] = {0,0}; 3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.getFloatv(GL_ALIASED_POINT_SIZE_RANGE, pointSizeRange); 3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (pointSizeRange[1] < pointSize) 3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::NotSupportedError("Maximum point size is too low for this test"); 3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid checkLineWidth (const glw::Functions& gl, float lineWidth) 3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLfloat lineWidthRange[2] = {0,0}; 3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.getFloatv(GL_ALIASED_LINE_WIDTH_RANGE, lineWidthRange); 3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (lineWidthRange[1] < lineWidth) 3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::NotSupportedError("Maximum line width is too low for this test"); 3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytcu::Vec3 IVec3ToVec3 (const tcu::IVec3& v) 3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return tcu::Vec3((float)v.x(), (float)v.y(), (float)v.z()); 3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool pointOnTriangle (const tcu::IVec3& p, const tcu::IVec3& t0, const tcu::IVec3& t1, const tcu::IVec3& t2) 3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Must be on the plane 3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::IVec3 n = tcu::cross(t1 - t0, t2 - t0); 3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::IVec3 d = (p - t0); 3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (tcu::dot(n, d)) 3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Must be within the triangle area 3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (deSign32(tcu::dot(n, tcu::cross(t1 - t0, p - t0))) == deSign32(tcu::dot(n, tcu::cross(t2 - t0, p - t0)))) 3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (deSign32(tcu::dot(n, tcu::cross(t2 - t1, p - t1))) == deSign32(tcu::dot(n, tcu::cross(t0 - t1, p - t1)))) 3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (deSign32(tcu::dot(n, tcu::cross(t0 - t2, p - t2))) == deSign32(tcu::dot(n, tcu::cross(t1 - t2, p - t2)))) 3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return true; 3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool pointsOnLine (const tcu::IVec2& t0, const tcu::IVec2& t1, const tcu::IVec2& t2) 3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return (t1 - t0).x() * (t2 - t0).y() - (t2 - t0).x() * (t1 - t0).y() == 0; 3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// returns true for cases where polygon is (almost) along xz or yz planes (normal.z < 0.1) 3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// \note[jarkko] Doesn't have to be accurate, just to detect some obviously bad cases 3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool twoPointClippedTriangleInvisible(const tcu::Vec3& p, const tcu::IVec3& dir1, const tcu::IVec3& dir2) 3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // fixed-point-like coords 3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deInt64 fixedScale = 64; 3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deInt64 farValue = 1024; 3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vector<deInt64, 3> d1 = tcu::Vector<deInt64, 3>(dir1.x(), dir1.y(), dir1.z()); 3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vector<deInt64, 3> d2 = tcu::Vector<deInt64, 3>(dir2.x(), dir2.y(), dir2.z()); 3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vector<deInt64, 3> pfixed = tcu::Vector<deInt64, 3>(deFloorFloatToInt32(p.x() * fixedScale), deFloorFloatToInt32(p.y() * fixedScale), deFloorFloatToInt32(p.z() * fixedScale)); 3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vector<deInt64, 3> normalDir = tcu::cross(d1*farValue - pfixed, d2*farValue - pfixed); 3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deInt64 normalLen2 = tcu::lengthSquared(normalDir); 3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return (normalDir.z() * normalDir.z() - normalLen2/100) < 0; 3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::string genClippingPointInfoString(const tcu::Vec4& p) 3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::ostringstream msg; 3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (p.x() < -p.w()) msg << "\t(-X clip)"; 3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (p.x() > p.w()) msg << "\t(+X clip)"; 3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (p.y() < -p.w()) msg << "\t(-Y clip)"; 3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (p.y() > p.w()) msg << "\t(+Y clip)"; 3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (p.z() < -p.w()) msg << "\t(-Z clip)"; 3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (p.z() > p.w()) msg << "\t(+Z clip)"; 3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return msg.str(); 3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::string genColorString(const tcu::Vec4& p) 3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 white (1.0f, 1.0f, 1.0f, 1.0f); 3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 red (1.0f, 0.0f, 0.0f, 1.0f); 3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 yellow (1.0f, 1.0f, 0.0f, 1.0f); 3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 blue (0.0f, 0.0f, 1.0f, 1.0f); 3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (p == white) return "(white)"; 3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (p == red) return "(red)"; 3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (p == yellow) return "(yellow)"; 3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (p == blue) return "(blue)"; 3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return ""; 3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass PositionColorShader : public sglr::ShaderProgram 3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum 3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry VARYINGLOC_COLOR = 0 3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PositionColorShader (void); 4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void shadeVertices (const rr::VertexAttrib* inputs, rr::VertexPacket* const* packets, const int numPackets) const; 4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void shadeFragments (rr::FragmentPacket* packets, const int numPackets, const rr::FragmentShadingContext& context) const; 4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4053c827367444ee418f129b2c238299f49d3264554Jarkko PoyryPositionColorShader::PositionColorShader (void) 4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : sglr::ShaderProgram(sglr::pdec::ShaderProgramDeclaration() 4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << sglr::pdec::VertexAttribute("a_position", rr::GENERICVECTYPE_FLOAT) 4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << sglr::pdec::VertexAttribute("a_color", rr::GENERICVECTYPE_FLOAT) 4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << sglr::pdec::VertexAttribute("a_pointSize", rr::GENERICVECTYPE_FLOAT) 4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << sglr::pdec::VertexToFragmentVarying(rr::GENERICVECTYPE_FLOAT) 4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << sglr::pdec::FragmentOutput(rr::GENERICVECTYPE_FLOAT) 4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << sglr::pdec::VertexSource(shaderSourceVertex) 4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << sglr::pdec::FragmentSource(shaderSourceFragment)) 4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid PositionColorShader::shadeVertices (const rr::VertexAttrib* inputs, rr::VertexPacket* const* packets, const int numPackets) const 4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int packetNdx = 0; packetNdx < numPackets; ++packetNdx) 4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int positionAttrLoc = 0; 4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int colorAttrLoc = 1; 4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int pointSizeAttrLoc = 2; 4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry rr::VertexPacket& packet = *packets[packetNdx]; 4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Transform to position 4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry packet.position = rr::readVertexAttribFloat(inputs[positionAttrLoc], packet.instanceNdx, packet.vertexNdx); 4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // output point size 4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry packet.pointSize = rr::readVertexAttribFloat(inputs[pointSizeAttrLoc], packet.instanceNdx, packet.vertexNdx).x(); 4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Pass color to FS 4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry packet.outputs[VARYINGLOC_COLOR] = rr::readVertexAttribFloat(inputs[colorAttrLoc], packet.instanceNdx, packet.vertexNdx); 4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid PositionColorShader::shadeFragments (rr::FragmentPacket* packets, const int numPackets, const rr::FragmentShadingContext& context) const 4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int packetNdx = 0; packetNdx < numPackets; ++packetNdx) 4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry rr::FragmentPacket& packet = packets[packetNdx]; 4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int fragNdx = 0; fragNdx < 4; ++fragNdx) 4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry rr::writeFragmentOutput(context, packetNdx, fragNdx, 0, rr::readVarying<float>(packet, context, VARYINGLOC_COLOR, fragNdx)); 4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass RenderTestCase : public TestCase 4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RenderTestCase (Context& context, const char* name, const char* description); 4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void testRender (void) = DE_NULL; 4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void init (void) { } 4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4603c827367444ee418f129b2c238299f49d3264554Jarkko PoyryRenderTestCase::RenderTestCase (Context& context, const char* name, const char* description) 4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (context, name, description) 4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4653c827367444ee418f129b2c238299f49d3264554Jarkko PoyryRenderTestCase::IterateResult RenderTestCase::iterate (void) 4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int width = m_context.getRenderTarget().getWidth(); 4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int height = m_context.getRenderTarget().getHeight(); 4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << TestLog::Message << "Render target size: " << width << "x" << height << TestLog::EndMessage; 4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (width < TEST_CANVAS_SIZE || height < TEST_CANVAS_SIZE) 4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::NotSupportedError(std::string("Render target size must be at least ") + de::toString(TEST_CANVAS_SIZE) + "x" + de::toString(TEST_CANVAS_SIZE)); 4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); // success by default 4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry testRender(); 4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass PointCase : public RenderTestCase 4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PointCase (Context& context, const char* name, const char* description, const tcu::Vec4* pointsBegin, const tcu::Vec4* pointsEnd, float pointSize, const rr::WindowRectangle& viewport); 4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void testRender (void); 4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::vector<tcu::Vec4> m_points; 4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float m_pointSize; 4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const rr::WindowRectangle m_viewport; 4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4943c827367444ee418f129b2c238299f49d3264554Jarkko PoyryPointCase::PointCase (Context& context, const char* name, const char* description, const tcu::Vec4* pointsBegin, const tcu::Vec4* pointsEnd, float pointSize, const rr::WindowRectangle& viewport) 4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : RenderTestCase(context, name, description) 4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_points (pointsBegin, pointsEnd) 4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_pointSize (pointSize) 4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_viewport (viewport) 4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid PointCase::init (void) 5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry checkPointSize (gl, m_pointSize); 5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid PointCase::testRender (void) 5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using tcu::TestLog; 5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int numSamples = de::max(m_context.getRenderTarget().getNumSamples(), 1); 5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestLog& log = m_testCtx.getLog(); 5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::GLContext glesContext (m_context.getRenderContext(), log, 0, tcu::IVec4(0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE)); 5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::ReferenceContextLimits limits; 5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::ReferenceContextBuffers buffers (m_context.getRenderTarget().getPixelFormat(), m_context.getRenderTarget().getDepthBits(), 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE, numSamples); 5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::ReferenceContext refContext (limits, buffers.getColorbuffer(), buffers.getDepthbuffer(), buffers.getStencilbuffer()); 5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PositionColorShader program; 5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface testSurface (TEST_CANVAS_SIZE, TEST_CANVAS_SIZE); 5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface refSurface (TEST_CANVAS_SIZE, TEST_CANVAS_SIZE); 5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::Context* contexts[2] = {&glesContext, &refContext}; 5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface* surfaces[2] = {&testSurface, &refSurface}; 5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // log the purpose of the test 5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Viewport: left=" << m_viewport.left << "\tbottom=" << m_viewport.bottom << "\twidth=" << m_viewport.width << "\theight=" << m_viewport.height << TestLog::EndMessage; 5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Rendering points with point size " << m_pointSize << ". Coordinates:" << TestLog::EndMessage; 5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (size_t ndx = 0; ndx < m_points.size(); ++ndx) 5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message 5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\tx=" << m_points[ndx].x() 5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\ty=" << m_points[ndx].y() 5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\tz=" << m_points[ndx].z() 5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\tw=" << m_points[ndx].w() 5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\t" << genClippingPointInfoString(m_points[ndx]) 5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::EndMessage; 5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int contextNdx = 0; contextNdx < 2; ++contextNdx) 5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::Context& ctx = *contexts[contextNdx]; 5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface& dstSurface = *surfaces[contextNdx]; 5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 programId = ctx.createProgram(&program); 5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const GLint positionLoc = ctx.getAttribLocation(programId, "a_position"); 5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const GLint pointSizeLoc = ctx.getAttribLocation(programId, "a_pointSize"); 5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const GLint colorLoc = ctx.getAttribLocation(programId, "a_color"); 5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.clearColor (0, 0, 0, 1); 5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.clearDepthf (1.0f); 5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.viewport (m_viewport.left, m_viewport.bottom, m_viewport.width, m_viewport.height); 5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.useProgram (programId); 5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.enableVertexAttribArray (positionLoc); 5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.vertexAttribPointer (positionLoc, 4, GL_FLOAT, GL_FALSE, 0, &m_points[0]); 5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.vertexAttrib1f (pointSizeLoc, m_pointSize); 5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.vertexAttrib4f (colorLoc, 1.0f, 1.0f, 1.0f, 1.0f); 5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.drawArrays (GL_POINTS, 0, (glw::GLsizei)m_points.size()); 5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.disableVertexAttribArray (positionLoc); 5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.useProgram (0); 5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.deleteProgram (programId); 5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.finish (); 5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.readPixels(dstSurface, 0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE); 5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // do the comparison 5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface diffMask (TEST_CANVAS_SIZE, TEST_CANVAS_SIZE); 5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int kernelRadius = 1; 5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int faultyPixels; 5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Comparing images... " << TestLog::EndMessage; 5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Deviation within radius of " << kernelRadius << " is allowed." << TestLog::EndMessage; 5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry faultyPixels = compareBlackNonBlackImages(log, testSurface.getAccess(), refSurface.getAccess(), diffMask.getAccess(), kernelRadius); 5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (faultyPixels > 0) 5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::ImageSet("Images", "Image comparison") 5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("TestImage", "Test image", testSurface.getAccess()) 5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("ReferenceImage", "Reference image", refSurface.getAccess()) 5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("DifferenceMask", "Difference mask", diffMask.getAccess()) 5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::EndImageSet 5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message << "Got " << faultyPixels << " faulty pixel(s)." << tcu::TestLog::EndMessage; 5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got faulty pixels"); 5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass LineRenderTestCase : public RenderTestCase 5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry struct ColoredLineData 5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 p0; 5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 c0; 5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 p1; 5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 c1; 5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry struct ColorlessLineData 6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 p0; 6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 p1; 6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry LineRenderTestCase (Context& context, const char* name, const char* description, const ColoredLineData* linesBegin, const ColoredLineData* linesEnd, float lineWidth, const rr::WindowRectangle& viewport); 6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry LineRenderTestCase (Context& context, const char* name, const char* description, const ColorlessLineData* linesBegin, const ColorlessLineData* linesEnd, float lineWidth, const rr::WindowRectangle& viewport); 6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void verifyImage (const tcu::ConstPixelBufferAccess& testImageAccess, const tcu::ConstPixelBufferAccess& referenceImageAccess) = DE_NULL; 6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void testRender (void); 6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 612f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyryprotected: 613f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry const float m_lineWidth; 614f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry 6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<ColoredLineData> convertToColoredLines (const ColorlessLineData* linesBegin, const ColorlessLineData* linesEnd); 6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::vector<ColoredLineData> m_lines; 6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const rr::WindowRectangle m_viewport; 6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6223c827367444ee418f129b2c238299f49d3264554Jarkko PoyryLineRenderTestCase::LineRenderTestCase (Context& context, const char* name, const char* description, const ColoredLineData* linesBegin, const ColoredLineData* linesEnd, float lineWidth, const rr::WindowRectangle& viewport) 6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : RenderTestCase (context, name, description) 6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_lineWidth (lineWidth) 625f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry , m_lines (linesBegin, linesEnd) 6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_viewport (viewport) 6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6303c827367444ee418f129b2c238299f49d3264554Jarkko PoyryLineRenderTestCase::LineRenderTestCase (Context& context, const char* name, const char* description, const ColorlessLineData* linesBegin, const ColorlessLineData* linesEnd, float lineWidth, const rr::WindowRectangle& viewport) 6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : RenderTestCase (context, name, description) 6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_lineWidth (lineWidth) 633f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry , m_lines (convertToColoredLines(linesBegin, linesEnd)) 6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_viewport (viewport) 6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid LineRenderTestCase::init (void) 6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry checkLineWidth (gl, m_lineWidth); 6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid LineRenderTestCase::testRender (void) 6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using tcu::TestLog; 6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int numSamples = de::max(m_context.getRenderTarget().getNumSamples(), 1); 6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int verticesPerLine = 2; 6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestLog& log = m_testCtx.getLog(); 6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::GLContext glesContext (m_context.getRenderContext(), log, 0, tcu::IVec4(0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE)); 6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::ReferenceContextLimits limits; 6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::ReferenceContextBuffers buffers (m_context.getRenderTarget().getPixelFormat(), m_context.getRenderTarget().getDepthBits(), 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE, numSamples); 6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::ReferenceContext refContext (limits, buffers.getColorbuffer(), buffers.getDepthbuffer(), buffers.getStencilbuffer()); 6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PositionColorShader program; 6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface testSurface (TEST_CANVAS_SIZE, TEST_CANVAS_SIZE); 6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface refSurface (TEST_CANVAS_SIZE, TEST_CANVAS_SIZE); 6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::Context* contexts[2] = {&glesContext, &refContext}; 6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface* surfaces[2] = {&testSurface, &refSurface}; 6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // log the purpose of the test 6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Viewport: left=" << m_viewport.left << "\tbottom=" << m_viewport.bottom << "\twidth=" << m_viewport.width << "\theight=" << m_viewport.height << TestLog::EndMessage; 6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Rendering lines with line width " << m_lineWidth << ". Coordinates:" << TestLog::EndMessage; 6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (size_t ndx = 0; ndx < m_lines.size(); ++ndx) 6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string fromProperties = genClippingPointInfoString(m_lines[ndx].p0); 6683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string toProperties = genClippingPointInfoString(m_lines[ndx].p1); 6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 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; 6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 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; 6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << TestLog::EndMessage; 6733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // render test image 6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int contextNdx = 0; contextNdx < 2; ++contextNdx) 6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::Context& ctx = *contexts[contextNdx]; 6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface& dstSurface = *surfaces[contextNdx]; 6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 programId = ctx.createProgram(&program); 6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const GLint positionLoc = ctx.getAttribLocation(programId, "a_position"); 6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const GLint colorLoc = ctx.getAttribLocation(programId, "a_color"); 6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.clearColor (0, 0, 0, 1); 6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.clearDepthf (1.0f); 6863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.viewport (m_viewport.left, m_viewport.bottom, m_viewport.width, m_viewport.height); 6883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.useProgram (programId); 6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.enableVertexAttribArray (positionLoc); 6903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.enableVertexAttribArray (colorLoc); 6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.vertexAttribPointer (positionLoc, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat[8]), &m_lines[0].p0); 6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.vertexAttribPointer (colorLoc, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat[8]), &m_lines[0].c0); 6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.lineWidth (m_lineWidth); 6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.drawArrays (GL_LINES, 0, verticesPerLine * (glw::GLsizei)m_lines.size()); 6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.disableVertexAttribArray (positionLoc); 6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.disableVertexAttribArray (colorLoc); 6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.useProgram (0); 6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.deleteProgram (programId); 6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.finish (); 7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.readPixels(dstSurface, 0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE); 7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // compare 7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry verifyImage(testSurface.getAccess(), refSurface.getAccess()); 7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::vector<LineRenderTestCase::ColoredLineData> LineRenderTestCase::convertToColoredLines(const ColorlessLineData* linesBegin, const ColorlessLineData* linesEnd) 7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<ColoredLineData> ret; 7113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (const ColorlessLineData* it = linesBegin; it != linesEnd; ++it) 7133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ColoredLineData r; 7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry r.p0 = (*it).p0; 7173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry r.c0 = tcu::Vec4(1, 1, 1, 1); 7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry r.p1 = (*it).p1; 7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry r.c1 = tcu::Vec4(1, 1, 1, 1); 7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ret.push_back(r); 7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return ret; 7253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass LineCase : public LineRenderTestCase 7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7293c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 7303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 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); 7313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void verifyImage (const tcu::ConstPixelBufferAccess& testImageAccess, const tcu::ConstPixelBufferAccess& referenceImageAccess); 7333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7343c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 7353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int m_searchKernelSize; 7363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 7373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7383c827367444ee418f129b2c238299f49d3264554Jarkko PoyryLineCase::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) 7393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : LineRenderTestCase (context, name, description, linesBegin, linesEnd, lineWidth, viewport) 7403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_searchKernelSize (searchKernelSize) 7413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid LineCase::verifyImage (const tcu::ConstPixelBufferAccess& testImageAccess, const tcu::ConstPixelBufferAccess& referenceImageAccess) 7453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 746f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry const int faultyLimit = 6; 747f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry int faultyPixels; 7483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 749f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry const bool isMsaa = m_context.getRenderTarget().getNumSamples() > 1; 750f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry tcu::TestLog& log = m_testCtx.getLog(); 751f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry tcu::Surface diffMask (TEST_CANVAS_SIZE, TEST_CANVAS_SIZE); 7523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Comparing images... " << TestLog::EndMessage; 7543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Deviation within radius of " << m_searchKernelSize << " is allowed." << TestLog::EndMessage; 7553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << faultyLimit << " faulty pixels are allowed." << TestLog::EndMessage; 7563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry faultyPixels = compareBlackNonBlackImages(log, testImageAccess, referenceImageAccess, diffMask.getAccess(), m_searchKernelSize); 7583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (faultyPixels > faultyLimit) 7603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::ImageSet("Images", "Image comparison") 7623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("TestImage", "Test image", testImageAccess) 7633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("ReferenceImage", "Reference image", referenceImageAccess) 7643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("DifferenceMask", "Difference mask", diffMask.getAccess()) 7653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::EndImageSet 7663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message << "Got " << faultyPixels << " faulty pixel(s)." << tcu::TestLog::EndMessage; 7673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 768f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry if (m_lineWidth != 1.0f && isMsaa) 769f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry { 770f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry log << TestLog::Message << "Wide line support is optional, reporting compatibility warning." << TestLog::EndMessage; 771f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry m_testCtx.setTestResult(QP_TEST_RESULT_COMPATIBILITY_WARNING, "Wide line clipping failed"); 772f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry } 773f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry else 774f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got faulty pixels"); 7753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7783c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ColoredLineCase : public LineRenderTestCase 7793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7803c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 7813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ColoredLineCase (Context& context, const char* name, const char* description, const LineRenderTestCase::ColoredLineData* linesBegin, const LineRenderTestCase::ColoredLineData* linesEnd, float lineWidth, const rr::WindowRectangle& viewport); 7823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void verifyImage (const tcu::ConstPixelBufferAccess& testImageAccess, const tcu::ConstPixelBufferAccess& referenceImageAccess); 7843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 7853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7863c827367444ee418f129b2c238299f49d3264554Jarkko PoyryColoredLineCase::ColoredLineCase (Context& context, const char* name, const char* description, const LineRenderTestCase::ColoredLineData* linesBegin, const LineRenderTestCase::ColoredLineData* linesEnd, float lineWidth, const rr::WindowRectangle& viewport) 7873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : LineRenderTestCase (context, name, description, linesBegin, linesEnd, lineWidth, viewport) 7883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7913c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ColoredLineCase::verifyImage (const tcu::ConstPixelBufferAccess& testImageAccess, const tcu::ConstPixelBufferAccess& referenceImageAccess) 7923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool msaa = m_context.getRenderTarget().getNumSamples() > 1; 7943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestLog& log = m_testCtx.getLog(); 7953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!msaa) 7973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int kernelRadius = 1; 7993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int faultyLimit = 6; 8003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int faultyPixels; 8013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface diffMask (TEST_CANVAS_SIZE, TEST_CANVAS_SIZE); 8023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Comparing images... " << TestLog::EndMessage; 8043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Deviation within radius of " << kernelRadius << " is allowed." << TestLog::EndMessage; 8053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << faultyLimit << " faulty pixels are allowed." << TestLog::EndMessage; 8063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry faultyPixels = compareColoredImages(log, testImageAccess, referenceImageAccess, diffMask.getAccess(), kernelRadius); 8083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (faultyPixels > faultyLimit) 8103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 8113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::ImageSet("Images", "Image comparison") 8123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("TestImage", "Test image", testImageAccess) 8133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("ReferenceImage", "Reference image", referenceImageAccess) 8143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("DifferenceMask", "Difference mask", diffMask.getAccess()) 8153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::EndImageSet 8163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message << "Got " << faultyPixels << " faulty pixel(s)." << tcu::TestLog::EndMessage; 8173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got faulty pixels"); 8193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 8203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 8213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 8223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 8233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float threshold = 0.3f; 8243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!tcu::fuzzyCompare(log, "Images", "", referenceImageAccess, testImageAccess, threshold, tcu::COMPARE_LOG_ON_ERROR)) 825f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry { 826f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry if (m_lineWidth != 1.0f) 827f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry { 828f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry log << TestLog::Message << "Wide line support is optional, reporting compatibility warning." << TestLog::EndMessage; 829f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry m_testCtx.setTestResult(QP_TEST_RESULT_COMPATIBILITY_WARNING, "Wide line clipping failed"); 830f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry } 831f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry else 832f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got faulty pixels"); 833f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry } 8343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 8353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 8363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8373c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TriangleCaseBase : public RenderTestCase 8383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8393c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 8403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry struct TriangleData 8413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 8423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 p0; 8433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 c0; 8443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 p1; 8453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 c1; 8463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 p2; 8473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 c2; 8483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 8493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TriangleCaseBase (Context& context, const char* name, const char* description, const TriangleData* polysBegin, const TriangleData* polysEnd, const rr::WindowRectangle& viewport); 8513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void verifyImage (const tcu::ConstPixelBufferAccess& testImageAccess, const tcu::ConstPixelBufferAccess& referenceImageAccess) = DE_NULL; 8533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void testRender (void); 8543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8553c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 8563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::vector<TriangleData> m_polys; 8573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const rr::WindowRectangle m_viewport; 8583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 8593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8603c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTriangleCaseBase::TriangleCaseBase (Context& context, const char* name, const char* description, const TriangleData* polysBegin, const TriangleData* polysEnd, const rr::WindowRectangle& viewport) 8613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : RenderTestCase(context, name, description) 8623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_polys (polysBegin, polysEnd) 8633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_viewport (viewport) 8643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 8663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8673c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TriangleCaseBase::testRender (void) 8683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using tcu::TestLog; 8703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int numSamples = de::max(m_context.getRenderTarget().getNumSamples(), 1); 8723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int verticesPerTriangle = 3; 8733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestLog& log = m_testCtx.getLog(); 8753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::GLContext glesContext (m_context.getRenderContext(), log, 0, tcu::IVec4(0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE)); 8763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::ReferenceContextLimits limits; 8773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::ReferenceContextBuffers buffers (m_context.getRenderTarget().getPixelFormat(), m_context.getRenderTarget().getDepthBits(), 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE, numSamples); 8783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::ReferenceContext refContext (limits, buffers.getColorbuffer(), buffers.getDepthbuffer(), buffers.getStencilbuffer()); 8793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PositionColorShader program; 8803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface testSurface (TEST_CANVAS_SIZE, TEST_CANVAS_SIZE); 8813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface refSurface (TEST_CANVAS_SIZE, TEST_CANVAS_SIZE); 8823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::Context* contexts[2] = {&glesContext, &refContext}; 8833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface* surfaces[2] = {&testSurface, &refSurface}; 8843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // log the purpose of the test 8863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Viewport: left=" << m_viewport.left << "\tbottom=" << m_viewport.bottom << "\twidth=" << m_viewport.width << "\theight=" << m_viewport.height << TestLog::EndMessage; 8873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Rendering triangles. Coordinates:" << TestLog::EndMessage; 8883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (size_t ndx = 0; ndx < m_polys.size(); ++ndx) 8893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 8903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string v0Properties = genClippingPointInfoString(m_polys[ndx].p0); 8913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string v1Properties = genClippingPointInfoString(m_polys[ndx].p1); 8923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string v2Properties = genClippingPointInfoString(m_polys[ndx].p2); 8933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string c0Properties = genColorString(m_polys[ndx].c0); 8943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string c1Properties = genColorString(m_polys[ndx].c1); 8953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string c2Properties = genColorString(m_polys[ndx].c2); 8963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 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; 8983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 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; 8993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 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; 9003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << TestLog::EndMessage; 9013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 9023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // render test image 9043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int contextNdx = 0; contextNdx < 2; ++contextNdx) 9053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 9063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::Context& ctx = *contexts[contextNdx]; 9073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface& dstSurface = *surfaces[contextNdx]; 9083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 programId = ctx.createProgram(&program); 9093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const GLint positionLoc = ctx.getAttribLocation(programId, "a_position"); 9103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const GLint colorLoc = ctx.getAttribLocation(programId, "a_color"); 9113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.clearColor (0, 0, 0, 1); 9133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.clearDepthf (1.0f); 9143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 9153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.viewport (m_viewport.left, m_viewport.bottom, m_viewport.width, m_viewport.height); 9163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.useProgram (programId); 9173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.enableVertexAttribArray (positionLoc); 9183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.enableVertexAttribArray (colorLoc); 9193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.vertexAttribPointer (positionLoc, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat[8]), &m_polys[0].p0); 9203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.vertexAttribPointer (colorLoc, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat[8]), &m_polys[0].c0); 9213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.drawArrays (GL_TRIANGLES, 0, verticesPerTriangle * (glw::GLsizei)m_polys.size()); 9223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.disableVertexAttribArray (positionLoc); 9233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.disableVertexAttribArray (colorLoc); 9243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.useProgram (0); 9253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.deleteProgram (programId); 9263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.finish (); 9273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.readPixels(dstSurface, 0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE); 9293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 9303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry verifyImage(testSurface.getAccess(), refSurface.getAccess()); 9323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 9333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9343c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TriangleCase : public TriangleCaseBase 9353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9363c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 9373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TriangleCase (Context& context, const char* name, const char* description, const TriangleData* polysBegin, const TriangleData* polysEnd, const rr::WindowRectangle& viewport); 9383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void verifyImage (const tcu::ConstPixelBufferAccess& testImageAccess, const tcu::ConstPixelBufferAccess& referenceImageAccess); 9403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 9413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9423c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTriangleCase::TriangleCase (Context& context, const char* name, const char* description, const TriangleData* polysBegin, const TriangleData* polysEnd, const rr::WindowRectangle& viewport) 9433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TriangleCaseBase(context, name, description, polysBegin, polysEnd, viewport) 9443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 9463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TriangleCase::verifyImage (const tcu::ConstPixelBufferAccess& testImageAccess, const tcu::ConstPixelBufferAccess& referenceImageAccess) 9483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int kernelRadius = 1; 9503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int faultyLimit = 6; 9513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestLog& log = m_testCtx.getLog(); 9523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface diffMask (TEST_CANVAS_SIZE, TEST_CANVAS_SIZE); 9533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int faultyPixels; 9543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Comparing images... " << TestLog::EndMessage; 9563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Deviation within radius of " << kernelRadius << " is allowed." << TestLog::EndMessage; 9573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << faultyLimit << " faulty pixels are allowed." << TestLog::EndMessage; 9583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry faultyPixels = compareBlackNonBlackImages(log, testImageAccess, referenceImageAccess, diffMask.getAccess(), kernelRadius); 9603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (faultyPixels > faultyLimit) 9623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 9633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::ImageSet("Images", "Image comparison") 9643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("TestImage", "Test image", testImageAccess) 9653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("ReferenceImage", "Reference image", referenceImageAccess) 9663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("DifferenceMask", "Difference mask", diffMask.getAccess()) 9673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::EndImageSet 9683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message << "Got " << faultyPixels << " faulty pixel(s)." << tcu::TestLog::EndMessage; 9693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got faulty pixels"); 9713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 9723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 9733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9743c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TriangleAttributeCase : public TriangleCaseBase 9753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9763c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 9773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TriangleAttributeCase (Context& context, const char* name, const char* description, const TriangleData* polysBegin, const TriangleData* polysEnd, const rr::WindowRectangle& viewport); 9783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void verifyImage (const tcu::ConstPixelBufferAccess& testImageAccess, const tcu::ConstPixelBufferAccess& referenceImageAccess); 9803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 9813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9823c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTriangleAttributeCase::TriangleAttributeCase (Context& context, const char* name, const char* description, const TriangleData* polysBegin, const TriangleData* polysEnd, const rr::WindowRectangle& viewport) 9833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TriangleCaseBase(context, name, description, polysBegin, polysEnd, viewport) 9843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 9863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9873c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TriangleAttributeCase::verifyImage (const tcu::ConstPixelBufferAccess& testImageAccess, const tcu::ConstPixelBufferAccess& referenceImageAccess) 9883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool msaa = m_context.getRenderTarget().getNumSamples() > 1; 9903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestLog& log = m_testCtx.getLog(); 9913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!msaa) 9933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 9943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int kernelRadius = 1; 9953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int faultyLimit = 6; 9963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int faultyPixels; 9973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface diffMask (TEST_CANVAS_SIZE, TEST_CANVAS_SIZE); 9983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Comparing images... " << TestLog::EndMessage; 10003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Deviation within radius of " << kernelRadius << " is allowed." << TestLog::EndMessage; 10013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << faultyLimit << " faulty pixels are allowed." << TestLog::EndMessage; 10023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry faultyPixels = compareColoredImages(log, testImageAccess, referenceImageAccess, diffMask.getAccess(), kernelRadius); 10033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (faultyPixels > faultyLimit) 10053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::ImageSet("Images", "Image comparison") 10073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("TestImage", "Test image", testImageAccess) 10083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("ReferenceImage", "Reference image", referenceImageAccess) 10093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("DifferenceMask", "Difference mask", diffMask.getAccess()) 10103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::EndImageSet 10113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message << "Got " << faultyPixels << " faulty pixel(s)." << tcu::TestLog::EndMessage; 10123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got faulty pixels"); 10143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 10173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float threshold = 0.3f; 10193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!tcu::fuzzyCompare(log, "Images", "", referenceImageAccess, testImageAccess, threshold, tcu::COMPARE_LOG_ON_ERROR)) 10203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got faulty pixels"); 10213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 10233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10243c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass FillTest : public RenderTestCase 10253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 10263c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 10273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FillTest (Context& context, const char* name, const char* description, const rr::WindowRectangle& viewport); 10283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void render (sglr::Context& ctx) = DE_NULL; 10303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void testRender (void); 10313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10323c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 10333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const rr::WindowRectangle m_viewport; 10343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 10353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10363c827367444ee418f129b2c238299f49d3264554Jarkko PoyryFillTest::FillTest (Context& context, const char* name, const char* description, const rr::WindowRectangle& viewport) 10373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : RenderTestCase(context, name, description) 10383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_viewport (viewport) 10393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 10403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 10413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10423c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid FillTest::testRender (void) 10433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 10443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using tcu::TestLog; 10453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int numSamples = 1; 10473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestLog& log = m_testCtx.getLog(); 10493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::GLContext glesContext (m_context.getRenderContext(), log, 0, tcu::IVec4(0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE)); 10503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::ReferenceContextLimits limits; 10513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::ReferenceContextBuffers buffers (m_context.getRenderTarget().getPixelFormat(), m_context.getRenderTarget().getDepthBits(), 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE, numSamples); 10523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::ReferenceContext refContext (limits, buffers.getColorbuffer(), buffers.getDepthbuffer(), buffers.getStencilbuffer()); 10533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface testSurface (TEST_CANVAS_SIZE, TEST_CANVAS_SIZE); 10543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface refSurface (TEST_CANVAS_SIZE, TEST_CANVAS_SIZE); 10553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry render(glesContext); 10573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glesContext.readPixels(testSurface, 0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE); 10583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry render(refContext); 10603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry refContext.readPixels(refSurface, 0, 0, TEST_CANVAS_SIZE, TEST_CANVAS_SIZE); 10613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // check overdraw 10633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool overdrawOk; 10653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface outputImage(TEST_CANVAS_SIZE, TEST_CANVAS_SIZE); 10663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Checking for overdraw " << TestLog::EndMessage; 10683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry overdrawOk = checkHalfFilledImageOverdraw(log, m_context.getRenderTarget(), testSurface.getAccess(), outputImage.getAccess()); 10693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!overdrawOk) 10713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::ImageSet("Images", "Image comparison") 10733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("TestImage", "Test image", testSurface.getAccess()) 10743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("InvalidPixels", "Invalid pixels", outputImage.getAccess()) 10753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::EndImageSet 10763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message << "Got overdraw." << tcu::TestLog::EndMessage; 10773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got overdraw"); 10793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // compare & check missing pixels 10833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int kernelRadius = 1; 10853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface diffMask (TEST_CANVAS_SIZE, TEST_CANVAS_SIZE); 10863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int faultyPixels; 10873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Comparing images... " << TestLog::EndMessage; 10893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Deviation within radius of " << kernelRadius << " is allowed." << TestLog::EndMessage; 10903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry blitImageOnBlackSurface(refSurface.getAccess(), refSurface.getAccess()); // makes images look right in Candy 10923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry faultyPixels = compareBlackNonBlackImages(log, testSurface.getAccess(), refSurface.getAccess(), diffMask.getAccess(), kernelRadius); 10943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (faultyPixels > 0) 10963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::ImageSet("Images", "Image comparison") 10983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("TestImage", "Test image", testSurface.getAccess()) 10993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("ReferenceImage", "Reference image", refSurface.getAccess()) 11003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("DifferenceMask", "Difference mask", diffMask.getAccess()) 11013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::EndImageSet 11023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message << "Got " << faultyPixels << " faulty pixel(s)." << tcu::TestLog::EndMessage; 11033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got faulty pixels"); 11053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 11063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 11073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 11083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11093c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TriangleFillTest : public FillTest 11103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 11113c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 11123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry struct FillTriangle 11133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 v0; 11153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 c0; 11163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 v1; 11173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 c1; 11183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 v2; 11193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 c2; 11203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 11213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TriangleFillTest (Context& context, const char* name, const char* description, const rr::WindowRectangle& viewport); 11233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void render (sglr::Context& ctx); 11253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11263c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 11273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<FillTriangle> m_triangles; 11283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 11293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11303c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTriangleFillTest::TriangleFillTest (Context& context, const char* name, const char* description, const rr::WindowRectangle& viewport) 11313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : FillTest(context, name, description, viewport) 11323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 11333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 11343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11353c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TriangleFillTest::render (sglr::Context& ctx) 11363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 11373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int verticesPerTriangle = 3; 11383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PositionColorShader program; 11393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 programId = ctx.createProgram(&program); 11403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const GLint positionLoc = ctx.getAttribLocation(programId, "a_position"); 11413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const GLint colorLoc = ctx.getAttribLocation(programId, "a_color"); 11423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestLog& log = m_testCtx.getLog(); 11433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // log the purpose of the test 11453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Viewport: left=" << m_viewport.left << "\tbottom=" << m_viewport.bottom << "\twidth=" << m_viewport.width << "\theight=" << m_viewport.height << TestLog::EndMessage; 11463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Rendering triangles. Coordinates:" << TestLog::EndMessage; 11473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (size_t ndx = 0; ndx < m_triangles.size(); ++ndx) 11483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string v0Properties = genClippingPointInfoString(m_triangles[ndx].v0); 11503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string v1Properties = genClippingPointInfoString(m_triangles[ndx].v1); 11513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string v2Properties = genClippingPointInfoString(m_triangles[ndx].v2); 11523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 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; 11543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 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; 11553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 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; 11563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << TestLog::EndMessage; 11573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 11583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.clearColor (0, 0, 0, 1); 11603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.clearDepthf (1.0f); 11613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 11623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.viewport (m_viewport.left, m_viewport.bottom, m_viewport.width, m_viewport.height); 11633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.useProgram (programId); 11643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.blendFunc (GL_ONE, GL_ONE); 11653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.enable (GL_BLEND); 11663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.enableVertexAttribArray (positionLoc); 11673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.enableVertexAttribArray (colorLoc); 11683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.vertexAttribPointer (positionLoc, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat[8]), &m_triangles[0].v0); 11693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.vertexAttribPointer (colorLoc, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat[8]), &m_triangles[0].c0); 11703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.drawArrays (GL_TRIANGLES, 0, verticesPerTriangle * (glw::GLsizei)m_triangles.size()); 11713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.disableVertexAttribArray (positionLoc); 11723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.disableVertexAttribArray (colorLoc); 11733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.useProgram (0); 11743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.deleteProgram (programId); 11753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.finish (); 11763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 11773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11783c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass QuadFillTest : public TriangleFillTest 11793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 11803c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 11813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 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)); 11823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 11833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11843c827367444ee418f129b2c238299f49d3264554Jarkko PoyryQuadFillTest::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_) 11853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TriangleFillTest(context, name, description, viewport) 11863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 11873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float radius = 40000.0f; 11883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 center = tcu::Vec4(center_.x(), center_.y(), center_.z(), 1.0f); 11893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 halfWhite = tcu::Vec4(0.5f, 0.5f, 0.5f, 0.5f); 11903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 halfRed = tcu::Vec4(0.5f, 0.0f, 0.0f, 0.5f); 11913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 e1 = radius * tcu::Vec4(d1.x(), d1.y(), d1.z(), 0.0f); 11923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 e2 = radius * tcu::Vec4(d2.x(), d2.y(), d2.z(), 0.0f); 11933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FillTriangle triangle1; 11953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FillTriangle triangle2; 11963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry triangle1.c0 = halfWhite; 11983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry triangle1.c1 = halfWhite; 11993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry triangle1.c2 = halfWhite; 12003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry triangle1.v0 = center + e1 + e2; 12013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry triangle1.v1 = center + e1 - e2; 12023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry triangle1.v2 = center - e1 - e2; 12033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_triangles.push_back(triangle1); 12043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry triangle2.c0 = halfRed; 12063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry triangle2.c1 = halfRed; 12073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry triangle2.c2 = halfRed; 12083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry triangle2.v0 = center + e1 + e2; 12093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry triangle2.v1 = center - e1 - e2; 12103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry triangle2.v2 = center - e1 + e2; 12113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_triangles.push_back(triangle2); 12123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 12133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12143c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TriangleFanFillTest : public TriangleFillTest 12153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 12163c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 12173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TriangleFanFillTest (Context& context, const char* name, const char* description, const rr::WindowRectangle& viewport); 12183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 12193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12203c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTriangleFanFillTest::TriangleFanFillTest (Context& context, const char* name, const char* description, const rr::WindowRectangle& viewport) 12213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TriangleFillTest(context, name, description, viewport) 12223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 12233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float radius = 70000.0f; 12243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int trianglesPerVisit = 40; 12253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 center = tcu::Vec4(0, 0, 0, 1.0f); 12263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 halfWhite = tcu::Vec4(0.5f, 0.5f, 0.5f, 0.5f); 12273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 oddSliceColor = tcu::Vec4(0.0f, 0.0f, 0.5f, 0.0f); 12283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // create a continuous surface that goes through all 6 clip planes 12303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry /* 12323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * / / 12333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * /_ _ _ _ _ /x 12343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * | | | 12353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * | | / 12363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * | / --xe / 12373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * | | | / 12383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * |_ _ _ e _ _|/ 12393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 12403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * e = enter 12413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * x = exit 12423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry */ 12433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const struct ClipPlaneVisit 12443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 12453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec3 corner; 12463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec3 entryPoint; 12473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec3 exitPoint; 12483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } visits[] = 12493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 12503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { tcu::Vec3( 1, 1, 1), tcu::Vec3( 0, 1, 1), tcu::Vec3( 1, 0, 1) }, 12513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { tcu::Vec3( 1,-1, 1), tcu::Vec3( 1, 0, 1), tcu::Vec3( 1,-1, 0) }, 12523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { tcu::Vec3( 1,-1,-1), tcu::Vec3( 1,-1, 0), tcu::Vec3( 0,-1,-1) }, 12533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { tcu::Vec3(-1,-1,-1), tcu::Vec3( 0,-1,-1), tcu::Vec3(-1, 0,-1) }, 12543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { tcu::Vec3(-1, 1,-1), tcu::Vec3(-1, 0,-1), tcu::Vec3(-1, 1, 0) }, 12553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { tcu::Vec3(-1, 1, 1), tcu::Vec3(-1, 1, 0), tcu::Vec3( 0, 1, 1) }, 12563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 12573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(visits); ++ndx) 12593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 12603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const ClipPlaneVisit& visit = visits[ndx]; 12613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int tri = 0; tri < trianglesPerVisit; ++tri) 12633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 12643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec3 vertex0; 12653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec3 vertex1; 12663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (tri == 0) // first vertex is magic 12683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 12693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vertex0 = visit.entryPoint; 12703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 12713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 12723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 12733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec3 v1 = visit.entryPoint - visit.corner; 12743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec3 v2 = visit.exitPoint - visit.corner; 12753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vertex0 = visit.corner + tcu::normalize(tcu::mix(v1, v2, tcu::Vec3(float(tri)/trianglesPerVisit))); 12773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 12783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (tri == trianglesPerVisit-1) // last vertex is magic 12803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 12813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vertex1 = visit.exitPoint; 12823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 12833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 12843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 12853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec3 v1 = visit.entryPoint - visit.corner; 12863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec3 v2 = visit.exitPoint - visit.corner; 12873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vertex1 = visit.corner + tcu::normalize(tcu::mix(v1, v2, tcu::Vec3(float(tri+1)/trianglesPerVisit))); 12893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 12903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // write vec out 12923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 12933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FillTriangle triangle; 12943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry triangle.c0 = (tri % 2) ? halfWhite : halfWhite + oddSliceColor; 12963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry triangle.c1 = (tri % 2) ? halfWhite : halfWhite + oddSliceColor; 12973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry triangle.c2 = (tri % 2) ? halfWhite : halfWhite + oddSliceColor; 12983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry triangle.v0 = center; 12993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry triangle.v1 = tcu::Vec4(vertex0.x() * radius, vertex0.y() * radius, vertex0.z() * radius, 1.0f); 13003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry triangle.v2 = tcu::Vec4(vertex1.x() * radius, vertex1.y() * radius, vertex1.z() * radius, 1.0f); 13013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_triangles.push_back(triangle); 13033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 13043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 13063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 13073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 13083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13093c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass PointsTestGroup : public TestCaseGroup 13103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 13113c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 13123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PointsTestGroup (Context& context); 13133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 13153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 13163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13173c827367444ee418f129b2c238299f49d3264554Jarkko PoyryPointsTestGroup::PointsTestGroup (Context& context) 13183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(context, "point", "Point clipping tests") 13193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 13203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 13213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13223c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid PointsTestGroup::init (void) 13233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 13243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 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. 13253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 viewportTestPoints[] = 13273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 13283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // in clip volume 13293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), 13303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4( 0.1f, 0.1f, 0.1f, 1.0f), 13313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(-0.1f, 0.1f, -0.1f, 1.0f), 13323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(-0.1f, -0.1f, 0.1f, 1.0f), 13333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4( 0.1f, -0.1f, -0.1f, 1.0f), 13343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // in clip volume with w != 1 13363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4( 2.0f, 2.0f, 2.0f, 3.0f), 13373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(-2.0f, -2.0f, 2.0f, 3.0f), 13383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4( 0.5f, -0.5f, 0.5f, 0.7f), 13393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(-0.5f, 0.5f, -0.5f, 0.7f), 13403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // near the edge 13423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(-2.0f, -2.0f, 0.0f, 2.2f), 13433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4( 1.0f, -1.0f, 0.0f, 1.1f), 13443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(-1.0f, 1.0f, 0.0f, 1.1f), 13453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // not in the volume but still between near and far planes 13473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4( 1.3f, 0.0f, 0.0f, 1.0f), 13483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(-1.3f, 0.0f, 0.0f, 1.0f), 13493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4( 0.0f, 1.3f, 0.0f, 1.0f), 13503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4( 0.0f, -1.3f, 0.0f, 1.0f), 13513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(-1.3f, -1.3f, 0.0f, 1.0f), 13533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(-1.3f, 1.3f, 0.0f, 1.0f), 13543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4( 1.3f, 1.3f, 0.0f, 1.0f), 13553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4( 1.3f, -1.3f, 0.0f, 1.0f), 13563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // outside the viewport, wide points have fragments in the viewport 13583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4( littleOverViewport, littleOverViewport, 0.0f, 1.0f), 13593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4( 0.0f, littleOverViewport, 0.0f, 1.0f), 13603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4( littleOverViewport, 0.0f, 0.0f, 1.0f), 13613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 13623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 depthTestPoints[] = 13633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 13643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // in clip volume 13653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), 13663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4( 0.1f, 0.1f, 0.1f, 1.0f), 13673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(-0.1f, 0.1f, -0.1f, 1.0f), 13683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(-0.1f, -0.1f, 0.1f, 1.0f), 13693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4( 0.1f, -0.1f, -0.1f, 1.0f), 13703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // not between the near and the far planes. These should be clipped 13723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4( 0.1f, 0.0f, 1.1f, 1.0f), 13733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(-0.1f, 0.0f, -1.1f, 1.0f), 13743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(-0.0f, -0.1f, 1.1f, 1.0f), 13753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4( 0.0f, 0.1f, -1.1f, 1.0f) 13763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 13773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new PointCase(m_context, "point_z_clip", "point z clipping", DE_ARRAY_BEGIN(depthTestPoints), DE_ARRAY_END(depthTestPoints), 1.0f, VIEWPORT_WHOLE)); 13793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 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)); 13803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 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)); 13813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new PointCase(m_context, "point_clip_viewport_center", "point viewport clipping", DE_ARRAY_BEGIN(viewportTestPoints), DE_ARRAY_END(viewportTestPoints), 1.0f, VIEWPORT_CENTER)); 13833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new PointCase(m_context, "point_clip_viewport_corner", "point viewport clipping", DE_ARRAY_BEGIN(viewportTestPoints), DE_ARRAY_END(viewportTestPoints), 1.0f, VIEWPORT_CORNER)); 13843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new PointCase(m_context, "wide_point_z_clip", "point z clipping", DE_ARRAY_BEGIN(depthTestPoints), DE_ARRAY_END(depthTestPoints), 5.0f, VIEWPORT_WHOLE)); 13863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 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)); 13873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 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)); 13883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new PointCase(m_context, "wide_point_clip", "point viewport clipping", DE_ARRAY_BEGIN(viewportTestPoints), DE_ARRAY_END(viewportTestPoints), 5.0f, VIEWPORT_WHOLE)); 13903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 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)); 13913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 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)); 13923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 13933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13943c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass LinesTestGroup : public TestCaseGroup 13953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 13963c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 13973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry LinesTestGroup (Context& context); 13983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 14003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 14013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14023c827367444ee418f129b2c238299f49d3264554Jarkko PoyryLinesTestGroup::LinesTestGroup (Context& context) 14033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(context, "line", "Line clipping tests") 14043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 14053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 14063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14073c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid LinesTestGroup::init (void) 14083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 14093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 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. 14103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // lines 14123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const LineRenderTestCase::ColorlessLineData viewportTestLines[] = 14133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 14143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // from center to outside of viewport 14153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4( 0.0f, 1.5f, 0.0f, 1.0f)}, 14163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(-1.5f, 1.0f, 0.0f, 1.0f)}, 14173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(-1.5f, 0.0f, 0.0f, 1.0f)}, 14183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4( 0.2f, 0.4f, 1.5f, 1.0f)}, 14193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(-2.0f, -1.0f, 0.0f, 1.0f)}, 14203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4( 1.0f, 0.1f, 0.0f, 0.6f)}, 14213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // from outside to inside of viewport 14233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {tcu::Vec4( 1.5f, 0.0f, 0.0f, 1.0f), tcu::Vec4( 0.8f, -0.2f, 0.0f, 1.0f)}, 14243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {tcu::Vec4( 0.0f, -1.5f, 0.0f, 1.0f), tcu::Vec4( 0.9f, -0.7f, 0.0f, 1.0f)}, 14253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // from outside to outside 14273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {tcu::Vec4( 0.0f, -1.3f, 0.0f, 1.0f), tcu::Vec4( 1.3f, 0.0f, 0.0f, 1.0f)}, 14283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // outside the viewport, wide lines have fragments in the viewport 14303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {tcu::Vec4(-0.8f, -littleOverViewport, 0.0f, 1.0f), tcu::Vec4( 0.0f, -littleOverViewport, 0.0f, 1.0f)}, 14313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {tcu::Vec4(-littleOverViewport - 1.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4( 0.0f, -littleOverViewport - 1.0f, 0.0f, 1.0f)}, 14323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 14333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const LineRenderTestCase::ColorlessLineData depthTestLines[] = 14343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 14353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4( 1.3f, 1.0f, 2.0f, 1.0f)}, 14363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4( 1.3f, -1.0f, 2.0f, 1.0f)}, 14373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(-1.0f, -1.1f, -2.0f, 1.0f)}, 14383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(-1.0f, 1.1f, -2.0f, 1.0f)}, 14393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4( 1.0f, 0.1f, 2.0f, 0.6f)}, 14403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 14413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const LineRenderTestCase::ColorlessLineData longTestLines[] = 14423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 14433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {tcu::Vec4( -41000.0f, -40000.0f, -1000000.0f, 1.0f), tcu::Vec4( 41000.0f, 40000.0f, 1000000.0f, 1.0f)}, 14443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {tcu::Vec4( 41000.0f, -40000.0f, 1000000.0f, 1.0f), tcu::Vec4(-41000.0f, 40000.0f, -1000000.0f, 1.0f)}, 14453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {tcu::Vec4( 0.5f, -40000.0f, 100000.0f, 1.0f), tcu::Vec4( 0.5f, 40000.0f, -100000.0f, 1.0f)}, 14463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {tcu::Vec4( -0.5f, 40000.0f, 100000.0f, 1.0f), tcu::Vec4(-0.5f, -40000.0f, -100000.0f, 1.0f)}, 14473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 14483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // line attribute clipping 14503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 red (1.0f, 0.0f, 0.0f, 1.0f); 14513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 yellow (1.0f, 1.0f, 0.0f, 1.0f); 14523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 lightBlue (0.3f, 0.3f, 1.0f, 1.0f); 14533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const LineRenderTestCase::ColoredLineData colorTestLines[] = 14543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 14553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), red, tcu::Vec4( 1.3f, 1.0f, 2.0f, 1.0f), yellow }, 14563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), red, tcu::Vec4( 1.3f, -1.0f, 2.0f, 1.0f), lightBlue }, 14573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), red, tcu::Vec4(-1.0f, -1.0f, -2.0f, 1.0f), yellow }, 14583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {tcu::Vec4( 0.0f, 0.0f, 0.0f, 1.0f), red, tcu::Vec4(-1.0f, 1.0f, -2.0f, 1.0f), lightBlue }, 14593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 14603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // line clipping 14623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new LineCase(m_context, "line_z_clip", "line z clipping", DE_ARRAY_BEGIN(depthTestLines), DE_ARRAY_END(depthTestLines), 1.0f, VIEWPORT_WHOLE)); 14633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 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)); 14643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 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)); 14653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new LineCase(m_context, "line_clip_viewport_center", "line viewport clipping", DE_ARRAY_BEGIN(viewportTestLines), DE_ARRAY_END(viewportTestLines), 1.0f, VIEWPORT_CENTER)); 14673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new LineCase(m_context, "line_clip_viewport_corner", "line viewport clipping", DE_ARRAY_BEGIN(viewportTestLines), DE_ARRAY_END(viewportTestLines), 1.0f, VIEWPORT_CORNER)); 14683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new LineCase(m_context, "wide_line_z_clip", "line z clipping", DE_ARRAY_BEGIN(depthTestLines), DE_ARRAY_END(depthTestLines), 5.0f, VIEWPORT_WHOLE)); 14703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 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)); 14713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 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)); 14723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new LineCase(m_context, "wide_line_clip", "line viewport clipping", DE_ARRAY_BEGIN(viewportTestLines), DE_ARRAY_END(viewportTestLines), 5.0f, VIEWPORT_WHOLE)); 14743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 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)); 14753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 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)); 14763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new LineCase(m_context, "long_line_clip", "line viewport clipping", DE_ARRAY_BEGIN(longTestLines), DE_ARRAY_END(longTestLines), 1.0f, VIEWPORT_WHOLE, 2)); 14783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 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)); 14793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // line attribute clipping 14813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new ColoredLineCase(m_context, "line_attrib_clip", "line attribute clipping", DE_ARRAY_BEGIN(colorTestLines), DE_ARRAY_END(colorTestLines), 1.0f, VIEWPORT_WHOLE)); 14823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new ColoredLineCase(m_context, "wide_line_attrib_clip", "line attribute clipping", DE_ARRAY_BEGIN(colorTestLines), DE_ARRAY_END(colorTestLines), 5.0f, VIEWPORT_WHOLE)); 14833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 14843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14853c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass PolysTestGroup : public TestCaseGroup 14863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 14873c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 14883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PolysTestGroup (Context& context); 14893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 14913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 14923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14933c827367444ee418f129b2c238299f49d3264554Jarkko PoyryPolysTestGroup::PolysTestGroup (Context& context) 14943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(context, "polygon", "Polygon clipping tests") 14953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 14963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 14973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14983c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid PolysTestGroup::init (void) 14993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 15003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float large = 100000.0f; 15013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float offset = 0.9f; 15023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 white (1.0f, 1.0f, 1.0f, 1.0f); 15033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 red (1.0f, 0.0f, 0.0f, 1.0f); 15043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 yellow (1.0f, 1.0f, 0.0f, 1.0f); 15053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 blue (0.0f, 0.0f, 1.0f, 1.0f); 15063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // basic cases 15083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 15093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TriangleCase::TriangleData viewportPolys[] = 15103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 15113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // one vertex clipped 15123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 15133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // two vertices clipped 15153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 15163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // three vertices clipped 15183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 15193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 15203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 15213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TriangleCase::TriangleData depthPolys[] = 15223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 15233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // one vertex clipped to Z+ 15243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 15253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // two vertices clipped to Z- 15273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 15283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // three vertices clipped 15303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 15313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // three vertices clipped by X, Y and Z 15333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 15343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 15353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TriangleCase::TriangleData largePolys[] = 15363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 15373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // one vertex clipped 15383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 15393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // two vertices clipped 15413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 15423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // three vertices clipped 15443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 15453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 15463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TriangleCase::TriangleData largeDepthPolys[] = 15473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 15483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // one vertex clipped 15493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 15503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // two vertices clipped 15523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 15533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // three vertices clipped 15553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 15563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 15573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TriangleCase::TriangleData attribPolys[] = 15583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 15593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // one vertex clipped to edge, large 15603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 15613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // two vertices clipped to edges 15633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 15643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // two vertices clipped to edges, with non-uniform w 15663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 15673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // three vertices clipped, large, Z 15693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 15703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 15713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleCase(m_context, "poly_clip_viewport_center", "polygon viewport clipping", DE_ARRAY_BEGIN(viewportPolys), DE_ARRAY_END(viewportPolys), VIEWPORT_CENTER)); 15733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleCase(m_context, "poly_clip_viewport_corner", "polygon viewport clipping", DE_ARRAY_BEGIN(viewportPolys), DE_ARRAY_END(viewportPolys), VIEWPORT_CORNER)); 15743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleCase(m_context, "poly_z_clip", "polygon z clipping", DE_ARRAY_BEGIN(depthPolys), DE_ARRAY_END(depthPolys), VIEWPORT_WHOLE)); 15763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleCase(m_context, "poly_z_clip_viewport_center", "polygon z clipping", DE_ARRAY_BEGIN(depthPolys), DE_ARRAY_END(depthPolys), VIEWPORT_CENTER)); 15773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleCase(m_context, "poly_z_clip_viewport_corner", "polygon z clipping", DE_ARRAY_BEGIN(depthPolys), DE_ARRAY_END(depthPolys), VIEWPORT_CORNER)); 15783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleCase(m_context, "large_poly_clip_viewport_center", "polygon viewport clipping", DE_ARRAY_BEGIN(largePolys), DE_ARRAY_END(largePolys), VIEWPORT_CENTER)); 15803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleCase(m_context, "large_poly_clip_viewport_corner", "polygon viewport clipping", DE_ARRAY_BEGIN(largePolys), DE_ARRAY_END(largePolys), VIEWPORT_CORNER)); 15813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleCase(m_context, "large_poly_z_clip", "polygon z clipping", DE_ARRAY_BEGIN(largeDepthPolys), DE_ARRAY_END(largeDepthPolys), VIEWPORT_WHOLE)); 15833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleCase(m_context, "large_poly_z_clip_viewport_center", "polygon z clipping", DE_ARRAY_BEGIN(largeDepthPolys), DE_ARRAY_END(largeDepthPolys), VIEWPORT_CENTER)); 15843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleCase(m_context, "large_poly_z_clip_viewport_corner", "polygon z clipping", DE_ARRAY_BEGIN(largeDepthPolys), DE_ARRAY_END(largeDepthPolys), VIEWPORT_CORNER)); 15853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "poly_attrib_clip", "polygon clipping", DE_ARRAY_BEGIN(attribPolys), DE_ARRAY_END(attribPolys), VIEWPORT_WHOLE)); 15873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "poly_attrib_clip_viewport_center", "polygon clipping", DE_ARRAY_BEGIN(attribPolys), DE_ARRAY_END(attribPolys), VIEWPORT_CENTER)); 15883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "poly_attrib_clip_viewport_corner", "polygon clipping", DE_ARRAY_BEGIN(attribPolys), DE_ARRAY_END(attribPolys), VIEWPORT_CORNER)); 15893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 15903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // multiple polygons 15923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 15933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 15943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TriangleAttributeCase::TriangleData polys[] = 15953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 15963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // one vertex clipped to edge 15973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 15983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // two vertices clipped to edges 16003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 16013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // two vertices clipped to edges, with non-uniform w 16033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 16043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 16053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 16063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 16073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // three vertices clipped, Z 16093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 16103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 16113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_0", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_WHOLE)); 16133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_0_viewport_center", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER)); 16143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_0_viewport_corner", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER)); 16153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 16163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 16183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TriangleAttributeCase::TriangleData polys[] = 16193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 16203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // one vertex clipped to z 16213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 16223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // two vertices clipped to edges 16243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 16253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // two vertices clipped to edges, with non-uniform w 16273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 16283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 16293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 16303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 16313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 16323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_1", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_WHOLE)); 16343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_1_viewport_center", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER)); 16353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_1_viewport_corner", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER)); 16363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 16373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 16393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TriangleAttributeCase::TriangleData polys[] = 16403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 16413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // one vertex clipped to z 16423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 16433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // two vertices clipped to edges 16453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 16463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // two vertices clipped to edges 16483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 16493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 16503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 16513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 16523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 16533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_2", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_WHOLE)); 16553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_2_viewport_center", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER)); 16563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_2_viewport_corner", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER)); 16573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 16583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 16603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TriangleAttributeCase::TriangleData polys[] = 16613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 16623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // one vertex clipped to z 16633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 16643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // two vertices clipped to edges 16663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 16673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 16683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 16693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 16703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 16713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_3", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_WHOLE)); 16733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_3_viewport_center", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER)); 16743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_3_viewport_corner", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER)); 16753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 16763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 16783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TriangleAttributeCase::TriangleData polys[] = 16793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 16803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // one vertex clipped to z 16813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 16823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // two vertices clipped to edges 16843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 16853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 16863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 16873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 16883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 16893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_4", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_WHOLE)); 16913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_4_viewport_center", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER)); 16923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_4_viewport_corner", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER)); 16933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 16943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 16963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TriangleAttributeCase::TriangleData polys[] = 16973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 16983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // one vertex clipped to z 16993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 17003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // two vertices clipped to edges 17023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 17033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 17043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 17053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 17063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 17073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_5", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_WHOLE)); 17093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_5_viewport_center", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER)); 17103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_5_viewport_corner", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER)); 17113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 17123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 17143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TriangleAttributeCase::TriangleData polys[] = 17153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 17163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // one vertex clipped to z 17173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 17183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // two vertices clipped to edges 17203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 17213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 17223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 17233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 17243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 17253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_6", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_WHOLE)); 17273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_6_viewport_center", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER)); 17283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_6_viewport_corner", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER)); 17293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 17303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 17323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TriangleAttributeCase::TriangleData polys[] = 17333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 17343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // two vertices clipped to edges 17353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 17363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // two vertices clipped to edges 17383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 17393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 17403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 17413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 17423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 17433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_7", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_WHOLE)); 17453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_7_viewport_center", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER)); 17463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_7_viewport_corner", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER)); 17473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 17483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 17503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TriangleAttributeCase::TriangleData polys[] = 17513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 17523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // one vertex clipped to z 17533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 17543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // fill 17563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 17573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 17583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 17593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_8", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_WHOLE)); 17613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_8_viewport_center", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER)); 17623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_8_viewport_corner", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER)); 17633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 17643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 17663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TriangleAttributeCase::TriangleData polys[] = 17673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 17683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // one vertex clipped to z 17693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 17703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // fill 17723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 17733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 17743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 17753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_9", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_WHOLE)); 17773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_9_viewport_center", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER)); 17783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_9_viewport_corner", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER)); 17793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 17803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 17823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TriangleAttributeCase::TriangleData polys[] = 17833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 17843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // one vertex clipped to z 17853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 17863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // fill 17883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 17893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 17903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 17913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 17923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_10", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_WHOLE)); 17943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_10_viewport_center", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER)); 17953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_10_viewport_corner", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER)); 17963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 17973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 17993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TriangleAttributeCase::TriangleData polys[] = 18003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 18013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // one vertex clipped to z 18023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 18033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // fill 18053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 18063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 18073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 18083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry {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}, 18093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 18103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_11", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_WHOLE)); 18123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_11_viewport_center", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CENTER)); 18133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleAttributeCase(m_context, "multiple_11_viewport_corner", "polygon clipping", DE_ARRAY_BEGIN(polys), DE_ARRAY_END(polys), VIEWPORT_CORNER)); 18143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 18153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 18163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 18173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18183c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass PolyEdgesTestGroup : public TestCaseGroup 18193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 18203c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 18213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PolyEdgesTestGroup (Context& context); 18223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 18243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 18253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18263c827367444ee418f129b2c238299f49d3264554Jarkko PoyryPolyEdgesTestGroup::PolyEdgesTestGroup (Context& context) 18273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(context, "polygon_edge", "Polygon clipping edge tests") 18283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 18293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 18303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18313c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid PolyEdgesTestGroup::init (void) 18323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 18333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Quads via origin 18343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const struct Quad 18353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 18363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec3 d1; // tangent 18373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec3 d2; // bi-tangent 18383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } quads[] = 18393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 18403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { tcu::Vec3( 1, 1, 1), tcu::Vec3( 1, -1, 1) }, 18413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { tcu::Vec3( 1, 1, 1), tcu::Vec3(-1, 1.1f, 1) }, 18423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { tcu::Vec3( 1, 1, 0), tcu::Vec3(-1, 1, 0) }, 18433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { tcu::Vec3( 0, 1, 0), tcu::Vec3( 1, 0, 0) }, 18443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { tcu::Vec3( 0, 1, 0), tcu::Vec3( 1, 0.1f, 0) }, 18453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 18463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Quad near edge 18483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const struct EdgeQuad 18493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 18503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec3 d1; // tangent 18513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec3 d2; // bi-tangent 18523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec3 center; // center 18533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } edgeQuads[] = 18543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 18553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { tcu::Vec3( 1, 0.01f, 0 ), tcu::Vec3( 0, 0.01f, 0), tcu::Vec3( 0, 0.99f, 0 ) }, // edge near x-plane 18563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { tcu::Vec3( 0.01f, 1, 0 ), tcu::Vec3( 0.01f, 0, 0), tcu::Vec3( 0.99f, 0, 0 ) }, // edge near y-plane 18573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { tcu::Vec3( 1, 1, 0.01f), tcu::Vec3( 0.01f, -0.01f, 0), tcu::Vec3( 0, 0, 0.99f) }, // edge near z-plane 18583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 18593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(quads); ++ndx) 18613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 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)); 18623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(edgeQuads); ++ndx) 18633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 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)); 18643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Polyfan 18663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new TriangleFanFillTest(m_context, "poly_fan", "polygon edge clipping", VIEWPORT_CENTER)); 18673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 18683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18693c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass PolyVertexClipTestGroup : public TestCaseGroup 18703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 18713c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 18723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PolyVertexClipTestGroup (Context& context); 18733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 18753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 18763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18773c827367444ee418f129b2c238299f49d3264554Jarkko PoyryPolyVertexClipTestGroup::PolyVertexClipTestGroup (Context& context) 18783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(context, "triangle_vertex", "Clip n vertices") 18793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 18803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 18813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18823c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid PolyVertexClipTestGroup::init (void) 18833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 18843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float far = 30000.0f; 18853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::IVec3 outside[] = 18863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 18873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // outside one clipping plane 18883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::IVec3(-1, 0, 0), 18893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::IVec3( 1, 0, 0), 18903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::IVec3( 0, 1, 0), 18913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::IVec3( 0, -1, 0), 18923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::IVec3( 0, 0, 1), 18933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::IVec3( 0, 0, -1), 18943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // outside two clipping planes 18963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::IVec3(-1, -1, 0), 18973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::IVec3( 1, -1, 0), 18983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::IVec3( 1, 1, 0), 18993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::IVec3(-1, 1, 0), 19003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::IVec3(-1, 0, -1), 19023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::IVec3( 1, 0, -1), 19033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::IVec3( 1, 0, 1), 19043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::IVec3(-1, 0, 1), 19053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::IVec3( 0, -1, -1), 19073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::IVec3( 0, 1, -1), 19083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::IVec3( 0, 1, 1), 19093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::IVec3( 0, -1, 1), 19103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // outside three clipping planes 19123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::IVec3(-1, -1, 1), 19133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::IVec3( 1, -1, 1), 19143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::IVec3( 1, 1, 1), 19153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::IVec3(-1, 1, 1), 19163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::IVec3(-1, -1, -1), 19183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::IVec3( 1, -1, -1), 19193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::IVec3( 1, 1, -1), 19203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::IVec3(-1, 1, -1), 19213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 19223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random rnd(0xabcdef); 19243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestCaseGroup* clipOne = new TestCaseGroup(m_context, "clip_one", "Clip one vertex"); 19263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestCaseGroup* clipTwo = new TestCaseGroup(m_context, "clip_two", "Clip two vertices"); 19273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestCaseGroup* clipThree = new TestCaseGroup(m_context, "clip_three", "Clip three vertices"); 19283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(clipOne); 19303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(clipTwo); 19313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(clipThree); 19323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Test 1 point clipped 19343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(outside); ++ndx) 19353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 19363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float w0 = rnd.getFloat(0.2f, 16.0f); 19373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float w1 = rnd.getFloat(0.2f, 16.0f); 19383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float w2 = rnd.getFloat(0.2f, 16.0f); 19393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 white = tcu::Vec4( 1, 1, 1, 1); 19403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec3 r0 = tcu::Vec3( 0.2f, 0.3f, 0); 19413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec3 r1 = tcu::Vec3(-0.3f, -0.4f, 0); 19423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec3 r2 = IVec3ToVec3(outside[ndx]) * far; 19433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 p0 = tcu::Vec4(r0.x() * w0, r0.y() * w0, r0.z() * w0, w0); 19443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 p1 = tcu::Vec4(r1.x() * w1, r1.y() * w1, r1.z() * w1, w1); 19453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 p2 = tcu::Vec4(r2.x() * w2, r2.y() * w2, r2.z() * w2, w2); 19463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string name = std::string("clip") + 19483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (outside[ndx].x() > 0 ? "_pos_x" : (outside[ndx].x() < 0 ? "_neg_x" : "")) + 19493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (outside[ndx].y() > 0 ? "_pos_y" : (outside[ndx].y() < 0 ? "_neg_y" : "")) + 19503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (outside[ndx].z() > 0 ? "_pos_z" : (outside[ndx].z() < 0 ? "_neg_z" : "")); 19513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TriangleCase::TriangleData triangle = {p0, white, p1, white, p2, white}; 19533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // don't try to test with degenerate (or almost degenerate) triangles 19553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (outside[ndx].x() == 0 && outside[ndx].y() == 0) 19563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 19573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry clipOne->addChild(new TriangleCase(m_context, name.c_str(), "clip one vertex", &triangle, &triangle + 1, VIEWPORT_CENTER)); 19593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 19603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Special triangles for "clip_z" cases, default triangles is not good, since it has very small visible area => problems with MSAA 19623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 19633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 white = tcu::Vec4(1.0f, 1.0f, 1.0f, 1.0f); 19643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TriangleCase::TriangleData posZTriangle = 19663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 19673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4( 0.0f, -0.7f, -0.9f, 1.0f), white, 19683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4( 0.8f, 0.0f, -0.7f, 1.0f), white, 19693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(-0.9f, 0.9f, 3.0f, 1.0f), white 19703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 19713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TriangleCase::TriangleData negZTriangle = 19723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 19733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4( 0.0f, -0.7f, 0.9f, 1.0f), white, 19743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4( 0.4f, 0.0f, 0.7f, 1.0f), white, 19753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(-0.9f, 0.9f, -3.0f, 1.0f), white 19763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 19773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry clipOne->addChild(new TriangleCase(m_context, "clip_pos_z", "clip one vertex", &posZTriangle, &posZTriangle + 1, VIEWPORT_CENTER)); 19793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry clipOne->addChild(new TriangleCase(m_context, "clip_neg_z", "clip one vertex", &negZTriangle, &negZTriangle + 1, VIEWPORT_CENTER)); 19803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 19813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Test 2 points clipped 19833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx1 = 0; ndx1 < DE_LENGTH_OF_ARRAY(outside); ++ndx1) 19843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx2 = ndx1 + 1; ndx2 < DE_LENGTH_OF_ARRAY(outside); ++ndx2) 19853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 19863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float w0 = rnd.getFloat(0.2f, 16.0f); 19873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float w1 = rnd.getFloat(0.2f, 16.0f); 19883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float w2 = rnd.getFloat(0.2f, 16.0f); 19893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 white = tcu::Vec4( 1, 1, 1, 1); 19903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec3 r0 = tcu::Vec3( 0.2f, 0.3f, 0); 19913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::IVec3 r1 = outside[ndx1]; 19923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::IVec3 r2 = outside[ndx2]; 19933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 p0 = tcu::Vec4(r0.x() * w0, r0.y() * w0, r0.z() * w0, w0); 19943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 p1 = tcu::Vec4(r1.x() * far * w1, r1.y() * far * w1, r1.z() * far * w1, w1); 19953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 p2 = tcu::Vec4(r2.x() * far * w2, r2.y() * far * w2, r2.z() * far * w2, w2); 19963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string name = std::string("clip") + 19983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (outside[ndx1].x() > 0 ? "_pos_x" : (outside[ndx1].x() < 0 ? "_neg_x" : "")) + 19993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (outside[ndx1].y() > 0 ? "_pos_y" : (outside[ndx1].y() < 0 ? "_neg_y" : "")) + 20003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (outside[ndx1].z() > 0 ? "_pos_z" : (outside[ndx1].z() < 0 ? "_neg_z" : "")) + 20013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "_and" + 20023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (outside[ndx2].x() > 0 ? "_pos_x" : (outside[ndx2].x() < 0 ? "_neg_x" : "")) + 20033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (outside[ndx2].y() > 0 ? "_pos_y" : (outside[ndx2].y() < 0 ? "_neg_y" : "")) + 20043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (outside[ndx2].z() > 0 ? "_pos_z" : (outside[ndx2].z() < 0 ? "_neg_z" : "")); 20053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TriangleCase::TriangleData triangle = {p0, white, p1, white, p2, white}; 20073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (twoPointClippedTriangleInvisible(r0, r1, r2)) 20093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 20103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry clipTwo->addChild(new TriangleCase(m_context, name.c_str(), "clip two vertices", &triangle, &triangle + 1, VIEWPORT_CENTER)); 20123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 20133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Test 3 points clipped 20153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx1 = 0; ndx1 < DE_LENGTH_OF_ARRAY(outside); ++ndx1) 20163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx2 = ndx1 + 1; ndx2 < DE_LENGTH_OF_ARRAY(outside); ++ndx2) 20173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx3 = ndx2 + 1; ndx3 < DE_LENGTH_OF_ARRAY(outside); ++ndx3) 20183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 20193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float w0 = rnd.getFloat(0.2f, 16.0f); 20203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float w1 = rnd.getFloat(0.2f, 16.0f); 20213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float w2 = rnd.getFloat(0.2f, 16.0f); 20223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 white = tcu::Vec4(1, 1, 1, 1); 20233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::IVec3 r0 = outside[ndx1]; 20243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::IVec3 r1 = outside[ndx2]; 20253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::IVec3 r2 = outside[ndx3]; 20263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 p0 = tcu::Vec4(r0.x() * far * w0, r0.y() * far * w0, r0.z() * far * w0, w0); 20273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 p1 = tcu::Vec4(r1.x() * far * w1, r1.y() * far * w1, r1.z() * far * w1, w1); 20283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 p2 = tcu::Vec4(r2.x() * far * w2, r2.y() * far * w2, r2.z() * far * w2, w2); 20293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // ignore cases where polygon is along xz or yz planes 20313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (pointsOnLine(r0.swizzle(0, 1), r1.swizzle(0, 1), r2.swizzle(0, 1))) 20323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 20333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // triangle is visible only if it intersects the origin 20353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (pointOnTriangle(tcu::IVec3(0, 0, 0), r0, r1, r2)) 20363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 20373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TriangleCase::TriangleData triangle = {p0, white, p1, white, p2, white}; 20383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string name = std::string("clip") + 20393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (outside[ndx1].x() > 0 ? "_pos_x" : (outside[ndx1].x() < 0 ? "_neg_x" : "")) + 20403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (outside[ndx1].y() > 0 ? "_pos_y" : (outside[ndx1].y() < 0 ? "_neg_y" : "")) + 20413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (outside[ndx1].z() > 0 ? "_pos_z" : (outside[ndx1].z() < 0 ? "_neg_z" : "")) + 20423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "_and" + 20433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (outside[ndx2].x() > 0 ? "_pos_x" : (outside[ndx2].x() < 0 ? "_neg_x" : "")) + 20443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (outside[ndx2].y() > 0 ? "_pos_y" : (outside[ndx2].y() < 0 ? "_neg_y" : "")) + 20453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (outside[ndx2].z() > 0 ? "_pos_z" : (outside[ndx2].z() < 0 ? "_neg_z" : "")) + 20463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "_and" + 20473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (outside[ndx3].x() > 0 ? "_pos_x" : (outside[ndx3].x() < 0 ? "_neg_x" : "")) + 20483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (outside[ndx3].y() > 0 ? "_pos_y" : (outside[ndx3].y() < 0 ? "_neg_y" : "")) + 20493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (outside[ndx3].z() > 0 ? "_pos_z" : (outside[ndx3].z() < 0 ? "_neg_z" : "")); 20503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry clipThree->addChild(new TriangleCase(m_context, name.c_str(), "clip three vertices", &triangle, &triangle + 1, VIEWPORT_CENTER)); 20523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 20533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 20543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 20553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // anonymous 20573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20583c827367444ee418f129b2c238299f49d3264554Jarkko PoyryClippingTests::ClippingTests (Context& context) 20593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(context, "clipping", "Clipping tests") 20603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 20613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 20623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20633c827367444ee418f129b2c238299f49d3264554Jarkko PoyryClippingTests::~ClippingTests (void) 20643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 20653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 20663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20673c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ClippingTests::init (void) 20683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 20693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new PointsTestGroup (m_context)); 20703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new LinesTestGroup (m_context)); 20713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new PolysTestGroup (m_context)); 20723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new PolyEdgesTestGroup (m_context)); 20733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new PolyVertexClipTestGroup(m_context)); 20743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 20753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional 20773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles2 20783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 2079