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