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