1*35238bceSAndroid Build Coastguard Worker #ifndef _TCURASTERIZATIONVERIFIER_HPP 2*35238bceSAndroid Build Coastguard Worker #define _TCURASTERIZATIONVERIFIER_HPP 3*35238bceSAndroid Build Coastguard Worker /*------------------------------------------------------------------------- 4*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program Tester Core 5*35238bceSAndroid Build Coastguard Worker * ---------------------------------------- 6*35238bceSAndroid Build Coastguard Worker * 7*35238bceSAndroid Build Coastguard Worker * Copyright 2014 The Android Open Source Project 8*35238bceSAndroid Build Coastguard Worker * 9*35238bceSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 10*35238bceSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 11*35238bceSAndroid Build Coastguard Worker * You may obtain a copy of the License at 12*35238bceSAndroid Build Coastguard Worker * 13*35238bceSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 14*35238bceSAndroid Build Coastguard Worker * 15*35238bceSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 16*35238bceSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 17*35238bceSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18*35238bceSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 19*35238bceSAndroid Build Coastguard Worker * limitations under the License. 20*35238bceSAndroid Build Coastguard Worker * 21*35238bceSAndroid Build Coastguard Worker *//*! 22*35238bceSAndroid Build Coastguard Worker * \file 23*35238bceSAndroid Build Coastguard Worker * \brief Rasterization verifier utils. 24*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/ 25*35238bceSAndroid Build Coastguard Worker 26*35238bceSAndroid Build Coastguard Worker #include "tcuDefs.hpp" 27*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp" 28*35238bceSAndroid Build Coastguard Worker #include "tcuSurface.hpp" 29*35238bceSAndroid Build Coastguard Worker #include "deMath.h" 30*35238bceSAndroid Build Coastguard Worker 31*35238bceSAndroid Build Coastguard Worker #include <vector> 32*35238bceSAndroid Build Coastguard Worker 33*35238bceSAndroid Build Coastguard Worker namespace tcu 34*35238bceSAndroid Build Coastguard Worker { 35*35238bceSAndroid Build Coastguard Worker 36*35238bceSAndroid Build Coastguard Worker enum CoverageType 37*35238bceSAndroid Build Coastguard Worker { 38*35238bceSAndroid Build Coastguard Worker COVERAGE_FULL = 0, // !< primitive fully covers the queried area 39*35238bceSAndroid Build Coastguard Worker COVERAGE_PARTIAL, // !< primitive coverage is either partial, or could be full, partial or none depending on rounding and/or fill rules 40*35238bceSAndroid Build Coastguard Worker COVERAGE_NONE, // !< primitive does not cover area at all 41*35238bceSAndroid Build Coastguard Worker 42*35238bceSAndroid Build Coastguard Worker COVERAGE_LAST 43*35238bceSAndroid Build Coastguard Worker }; 44*35238bceSAndroid Build Coastguard Worker 45*35238bceSAndroid Build Coastguard Worker enum VerificationMode 46*35238bceSAndroid Build Coastguard Worker { 47*35238bceSAndroid Build Coastguard Worker VERIFICATIONMODE_STRICT = 0, // !< do not allow even a single bad pixel 48*35238bceSAndroid Build Coastguard Worker VERIFICATIONMODE_WEAK, // !< allow some bad pixels 49*35238bceSAndroid Build Coastguard Worker VERIFICATIONMODE_WEAKER, // !< allow more bad pixels 50*35238bceSAndroid Build Coastguard Worker VERIFICATIONMODE_SMOOTH, // !< allow no missing pixels 51*35238bceSAndroid Build Coastguard Worker 52*35238bceSAndroid Build Coastguard Worker VERIFICATIONMODE_LAST 53*35238bceSAndroid Build Coastguard Worker }; 54*35238bceSAndroid Build Coastguard Worker 55*35238bceSAndroid Build Coastguard Worker enum LineInterpolationMethod 56*35238bceSAndroid Build Coastguard Worker { 57*35238bceSAndroid Build Coastguard Worker LINEINTERPOLATION_STRICTLY_CORRECT = 0, // !< line interpolation matches the specification 58*35238bceSAndroid Build Coastguard Worker LINEINTERPOLATION_PROJECTED, // !< line interpolation weights are otherwise correct, but they are projected onto major axis 59*35238bceSAndroid Build Coastguard Worker LINEINTERPOLATION_INCORRECT // !< line interpolation is incorrect 60*35238bceSAndroid Build Coastguard Worker }; 61*35238bceSAndroid Build Coastguard Worker 62*35238bceSAndroid Build Coastguard Worker struct TriangleSceneSpec 63*35238bceSAndroid Build Coastguard Worker { 64*35238bceSAndroid Build Coastguard Worker struct SceneTriangle 65*35238bceSAndroid Build Coastguard Worker { 66*35238bceSAndroid Build Coastguard Worker tcu::Vec4 positions[3]; 67*35238bceSAndroid Build Coastguard Worker tcu::Vec4 colors[3]; 68*35238bceSAndroid Build Coastguard Worker bool sharedEdge[3]; // !< is the edge i -> i+1 shared with another scene triangle SceneTriangletcu::TriangleSceneSpec::SceneTriangle69*35238bceSAndroid Build Coastguard Worker SceneTriangle() 70*35238bceSAndroid Build Coastguard Worker { 71*35238bceSAndroid Build Coastguard Worker // Other members are initialized in Vector constructor 72*35238bceSAndroid Build Coastguard Worker for (int i = 0; i < 3; i++) 73*35238bceSAndroid Build Coastguard Worker sharedEdge[i] = false; 74*35238bceSAndroid Build Coastguard Worker } 75*35238bceSAndroid Build Coastguard Worker }; 76*35238bceSAndroid Build Coastguard Worker 77*35238bceSAndroid Build Coastguard Worker std::vector<SceneTriangle> triangles; 78*35238bceSAndroid Build Coastguard Worker }; 79*35238bceSAndroid Build Coastguard Worker 80*35238bceSAndroid Build Coastguard Worker struct LineSceneSpec 81*35238bceSAndroid Build Coastguard Worker { LineSceneSpectcu::LineSceneSpec82*35238bceSAndroid Build Coastguard Worker LineSceneSpec() 83*35238bceSAndroid Build Coastguard Worker : isStrip(false) 84*35238bceSAndroid Build Coastguard Worker , isSmooth(false) 85*35238bceSAndroid Build Coastguard Worker , isRectangular(false) 86*35238bceSAndroid Build Coastguard Worker , stippleEnable(false) 87*35238bceSAndroid Build Coastguard Worker , verificationMode(VERIFICATIONMODE_STRICT) 88*35238bceSAndroid Build Coastguard Worker { 89*35238bceSAndroid Build Coastguard Worker } 90*35238bceSAndroid Build Coastguard Worker 91*35238bceSAndroid Build Coastguard Worker struct SceneLine 92*35238bceSAndroid Build Coastguard Worker { 93*35238bceSAndroid Build Coastguard Worker tcu::Vec4 positions[2]; 94*35238bceSAndroid Build Coastguard Worker tcu::Vec4 colors[2]; 95*35238bceSAndroid Build Coastguard Worker }; 96*35238bceSAndroid Build Coastguard Worker 97*35238bceSAndroid Build Coastguard Worker std::vector<SceneLine> lines; 98*35238bceSAndroid Build Coastguard Worker float lineWidth; 99*35238bceSAndroid Build Coastguard Worker bool isStrip; 100*35238bceSAndroid Build Coastguard Worker bool isSmooth; 101*35238bceSAndroid Build Coastguard Worker bool isRectangular; 102*35238bceSAndroid Build Coastguard Worker bool allowNonProjectedInterpolation; 103*35238bceSAndroid Build Coastguard Worker bool stippleEnable; 104*35238bceSAndroid Build Coastguard Worker uint32_t stippleFactor; 105*35238bceSAndroid Build Coastguard Worker uint16_t stipplePattern; 106*35238bceSAndroid Build Coastguard Worker VerificationMode verificationMode; 107*35238bceSAndroid Build Coastguard Worker }; 108*35238bceSAndroid Build Coastguard Worker 109*35238bceSAndroid Build Coastguard Worker struct PointSceneSpec 110*35238bceSAndroid Build Coastguard Worker { 111*35238bceSAndroid Build Coastguard Worker struct ScenePoint 112*35238bceSAndroid Build Coastguard Worker { 113*35238bceSAndroid Build Coastguard Worker tcu::Vec4 position; 114*35238bceSAndroid Build Coastguard Worker tcu::Vec4 color; 115*35238bceSAndroid Build Coastguard Worker float pointSize; 116*35238bceSAndroid Build Coastguard Worker }; 117*35238bceSAndroid Build Coastguard Worker 118*35238bceSAndroid Build Coastguard Worker std::vector<ScenePoint> points; 119*35238bceSAndroid Build Coastguard Worker }; 120*35238bceSAndroid Build Coastguard Worker 121*35238bceSAndroid Build Coastguard Worker struct RasterizationArguments 122*35238bceSAndroid Build Coastguard Worker { 123*35238bceSAndroid Build Coastguard Worker int numSamples; 124*35238bceSAndroid Build Coastguard Worker int subpixelBits; 125*35238bceSAndroid Build Coastguard Worker int redBits; 126*35238bceSAndroid Build Coastguard Worker int greenBits; 127*35238bceSAndroid Build Coastguard Worker int blueBits; 128*35238bceSAndroid Build Coastguard Worker }; 129*35238bceSAndroid Build Coastguard Worker 130*35238bceSAndroid Build Coastguard Worker struct VerifyTriangleGroupRasterizationLogStash 131*35238bceSAndroid Build Coastguard Worker { 132*35238bceSAndroid Build Coastguard Worker std::vector<std::string> messages; 133*35238bceSAndroid Build Coastguard Worker int missingPixels; 134*35238bceSAndroid Build Coastguard Worker int unexpectedPixels; 135*35238bceSAndroid Build Coastguard Worker tcu::Surface errorMask; 136*35238bceSAndroid Build Coastguard Worker bool result; 137*35238bceSAndroid Build Coastguard Worker }; 138*35238bceSAndroid Build Coastguard Worker 139*35238bceSAndroid Build Coastguard Worker struct VerifyTriangleGroupInterpolationLogStash 140*35238bceSAndroid Build Coastguard Worker { 141*35238bceSAndroid Build Coastguard Worker std::vector<std::string> messages; 142*35238bceSAndroid Build Coastguard Worker int invalidPixels; 143*35238bceSAndroid Build Coastguard Worker tcu::Surface errorMask; 144*35238bceSAndroid Build Coastguard Worker bool success; 145*35238bceSAndroid Build Coastguard Worker }; 146*35238bceSAndroid Build Coastguard Worker 147*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*! 148*35238bceSAndroid Build Coastguard Worker * \brief Calculates triangle coverage at given pixel 149*35238bceSAndroid Build Coastguard Worker * Calculates the coverage of a triangle given by three vertices. The 150*35238bceSAndroid Build Coastguard Worker * triangle should not be z-clipped. If multisample is false, the pixel 151*35238bceSAndroid Build Coastguard Worker * center is compared against the triangle. If multisample is true, the 152*35238bceSAndroid Build Coastguard Worker * whole pixel area is compared. 153*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/ 154*35238bceSAndroid Build Coastguard Worker CoverageType calculateTriangleCoverage(const tcu::Vec4 &p0, const tcu::Vec4 &p1, const tcu::Vec4 &p2, 155*35238bceSAndroid Build Coastguard Worker const tcu::IVec2 &pixel, const tcu::IVec2 &viewportSize, int subpixelBits, 156*35238bceSAndroid Build Coastguard Worker bool multisample); 157*35238bceSAndroid Build Coastguard Worker 158*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*! 159*35238bceSAndroid Build Coastguard Worker * \brief Calculates line coverage at given pixel 160*35238bceSAndroid Build Coastguard Worker * Calculates the coverage of a reactangle given by line coordinates and width. 161*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/ 162*35238bceSAndroid Build Coastguard Worker CoverageType calculateUnderestimateLineCoverage(const tcu::Vec4 &p0, const tcu::Vec4 &p1, const float lineWidth, 163*35238bceSAndroid Build Coastguard Worker const tcu::IVec2 &pixel, const tcu::IVec2 &viewportSize); 164*35238bceSAndroid Build Coastguard Worker 165*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*! 166*35238bceSAndroid Build Coastguard Worker * \brief Calculates triangle coverage at given pixel 167*35238bceSAndroid Build Coastguard Worker * Calculates the coverage of a triangle given by by three vertices. 168*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/ 169*35238bceSAndroid Build Coastguard Worker CoverageType calculateUnderestimateTriangleCoverage(const tcu::Vec4 &p0, const tcu::Vec4 &p1, const tcu::Vec4 &p2, 170*35238bceSAndroid Build Coastguard Worker const tcu::IVec2 &pixel, int subpixelBits, 171*35238bceSAndroid Build Coastguard Worker const tcu::IVec2 &viewportSize); 172*35238bceSAndroid Build Coastguard Worker 173*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*! 174*35238bceSAndroid Build Coastguard Worker * \brief Verify triangle rasterization result 175*35238bceSAndroid Build Coastguard Worker * Verifies pixels in the surface are rasterized within the bounds given 176*35238bceSAndroid Build Coastguard Worker * by RasterizationArguments. Triangles should not be z-clipped. 177*35238bceSAndroid Build Coastguard Worker * 178*35238bceSAndroid Build Coastguard Worker * Triangle colors are not used. The triangle is expected to be white. 179*35238bceSAndroid Build Coastguard Worker * If logStash is not NULL the results are not logged, but copied to stash. 180*35238bceSAndroid Build Coastguard Worker * 181*35238bceSAndroid Build Coastguard Worker * Returns false if invalid rasterization is found. 182*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/ 183*35238bceSAndroid Build Coastguard Worker bool verifyTriangleGroupRasterization(const tcu::Surface &surface, const TriangleSceneSpec &scene, 184*35238bceSAndroid Build Coastguard Worker const RasterizationArguments &args, tcu::TestLog &log, 185*35238bceSAndroid Build Coastguard Worker VerificationMode mode = VERIFICATIONMODE_STRICT, 186*35238bceSAndroid Build Coastguard Worker VerifyTriangleGroupRasterizationLogStash *logStash = DE_NULL, 187*35238bceSAndroid Build Coastguard Worker const bool vulkanLinesTest = false); 188*35238bceSAndroid Build Coastguard Worker 189*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*! 190*35238bceSAndroid Build Coastguard Worker * \brief Verify line rasterization result 191*35238bceSAndroid Build Coastguard Worker * Verifies pixels in the surface are rasterized within the bounds given 192*35238bceSAndroid Build Coastguard Worker * by RasterizationArguments. Lines should not be z-clipped. 193*35238bceSAndroid Build Coastguard Worker * 194*35238bceSAndroid Build Coastguard Worker * Line colors are not used. The line is expected to be white. 195*35238bceSAndroid Build Coastguard Worker * 196*35238bceSAndroid Build Coastguard Worker * Returns false if invalid rasterization is found. 197*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/ 198*35238bceSAndroid Build Coastguard Worker bool verifyLineGroupRasterization(const tcu::Surface &surface, const LineSceneSpec &scene, 199*35238bceSAndroid Build Coastguard Worker const RasterizationArguments &args, tcu::TestLog &log); 200*35238bceSAndroid Build Coastguard Worker 201*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*! 202*35238bceSAndroid Build Coastguard Worker * \brief Verify clipped line rasterization result 203*35238bceSAndroid Build Coastguard Worker * Verifies pixels in the surface are rasterized within the bounds given 204*35238bceSAndroid Build Coastguard Worker * by RasterizationArguments and by clipping the lines with a (-1, -1), (1, 1) 205*35238bceSAndroid Build Coastguard Worker * square. Lines should not be z-clipped. 206*35238bceSAndroid Build Coastguard Worker * 207*35238bceSAndroid Build Coastguard Worker * Line colors are not used. The line is expected to be white. Lines are 208*35238bceSAndroid Build Coastguard Worker * rasterized as two triangles. 209*35238bceSAndroid Build Coastguard Worker * 210*35238bceSAndroid Build Coastguard Worker * Returns false if invalid rasterization is found. 211*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/ 212*35238bceSAndroid Build Coastguard Worker bool verifyClippedTriangulatedLineGroupRasterization(const tcu::Surface &surface, const LineSceneSpec &scene, 213*35238bceSAndroid Build Coastguard Worker const RasterizationArguments &args, tcu::TestLog &log); 214*35238bceSAndroid Build Coastguard Worker 215*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*! 216*35238bceSAndroid Build Coastguard Worker * \brief Verify line rasterization result both clipped and non-clipped 217*35238bceSAndroid Build Coastguard Worker * 218*35238bceSAndroid Build Coastguard Worker * For details please see verifyLineGroupRasterization and 219*35238bceSAndroid Build Coastguard Worker * verifyClippedTriangulatedLineGroupRasterization 220*35238bceSAndroid Build Coastguard Worker * 221*35238bceSAndroid Build Coastguard Worker * Returns false if both rasterizations are invalid. 222*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/ 223*35238bceSAndroid Build Coastguard Worker bool verifyRelaxedLineGroupRasterization(const tcu::Surface &surface, const LineSceneSpec &scene, 224*35238bceSAndroid Build Coastguard Worker const RasterizationArguments &args, tcu::TestLog &log, 225*35238bceSAndroid Build Coastguard Worker const bool vulkanLinesTest = false, const bool strict = true); 226*35238bceSAndroid Build Coastguard Worker 227*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*! 228*35238bceSAndroid Build Coastguard Worker * \brief Verify point rasterization result 229*35238bceSAndroid Build Coastguard Worker * Verifies points in the surface are rasterized within the bounds given 230*35238bceSAndroid Build Coastguard Worker * by RasterizationArguments. Points should not be z-clipped. 231*35238bceSAndroid Build Coastguard Worker * 232*35238bceSAndroid Build Coastguard Worker * Point colors are not used. The point is expected to be white. 233*35238bceSAndroid Build Coastguard Worker * 234*35238bceSAndroid Build Coastguard Worker * Returns false if invalid rasterization is found. 235*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/ 236*35238bceSAndroid Build Coastguard Worker bool verifyPointGroupRasterization(const tcu::Surface &surface, const PointSceneSpec &scene, 237*35238bceSAndroid Build Coastguard Worker const RasterizationArguments &args, tcu::TestLog &log); 238*35238bceSAndroid Build Coastguard Worker 239*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*! 240*35238bceSAndroid Build Coastguard Worker * \brief Verify triangle color interpolation is valid 241*35238bceSAndroid Build Coastguard Worker * Verifies the color of a fragments of a colored triangle is in the 242*35238bceSAndroid Build Coastguard Worker * valid range. Triangles should not be z-clipped. 243*35238bceSAndroid Build Coastguard Worker * 244*35238bceSAndroid Build Coastguard Worker * The background is expected to be black. 245*35238bceSAndroid Build Coastguard Worker * 246*35238bceSAndroid Build Coastguard Worker * Returns false if invalid rasterization interpolation is found. 247*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/ 248*35238bceSAndroid Build Coastguard Worker bool verifyTriangleGroupInterpolation(const tcu::Surface &surface, const TriangleSceneSpec &scene, 249*35238bceSAndroid Build Coastguard Worker const RasterizationArguments &args, tcu::TestLog &log); 250*35238bceSAndroid Build Coastguard Worker 251*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*! 252*35238bceSAndroid Build Coastguard Worker * \brief Verify line color interpolation is valid 253*35238bceSAndroid Build Coastguard Worker * Verifies the color of a fragments of a colored line is in the 254*35238bceSAndroid Build Coastguard Worker * valid range. Lines should not be z-clipped. 255*35238bceSAndroid Build Coastguard Worker * 256*35238bceSAndroid Build Coastguard Worker * The background is expected to be black. 257*35238bceSAndroid Build Coastguard Worker * 258*35238bceSAndroid Build Coastguard Worker * Returns the detected interpolation method of the input image. 259*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/ 260*35238bceSAndroid Build Coastguard Worker LineInterpolationMethod verifyLineGroupInterpolation(const tcu::Surface &surface, const LineSceneSpec &scene, 261*35238bceSAndroid Build Coastguard Worker const RasterizationArguments &args, tcu::TestLog &log); 262*35238bceSAndroid Build Coastguard Worker 263*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*! 264*35238bceSAndroid Build Coastguard Worker * \brief Verify line color interpolation is valid 265*35238bceSAndroid Build Coastguard Worker * Verifies the color of a fragments of a colored line is in the 266*35238bceSAndroid Build Coastguard Worker * valid range. Lines should not be z-clipped. 267*35238bceSAndroid Build Coastguard Worker * 268*35238bceSAndroid Build Coastguard Worker * The background is expected to be black. The lines are rasterized 269*35238bceSAndroid Build Coastguard Worker * as two triangles. 270*35238bceSAndroid Build Coastguard Worker * 271*35238bceSAndroid Build Coastguard Worker * Returns false if invalid rasterization interpolation is found. 272*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/ 273*35238bceSAndroid Build Coastguard Worker bool verifyTriangulatedLineGroupInterpolation(const tcu::Surface &surface, const LineSceneSpec &scene, 274*35238bceSAndroid Build Coastguard Worker const RasterizationArguments &args, tcu::TestLog &log, 275*35238bceSAndroid Build Coastguard Worker const bool strictMode = true, 276*35238bceSAndroid Build Coastguard Worker const bool allowBresenhamForNonStrictLines = false); 277*35238bceSAndroid Build Coastguard Worker 278*35238bceSAndroid Build Coastguard Worker } // namespace tcu 279*35238bceSAndroid Build Coastguard Worker 280*35238bceSAndroid Build Coastguard Worker #endif // _TCURASTERIZATIONVERIFIER_HPP 281