Home | History | Annotate | Download | only in glshared
      1 #ifndef _GLSRASTERIZATIONTESTUTIL_HPP
      2 #define _GLSRASTERIZATIONTESTUTIL_HPP
      3 /*-------------------------------------------------------------------------
      4  * drawElements Quality Program OpenGL (ES) Module
      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 test utils.
     24  *//*--------------------------------------------------------------------*/
     25 
     26 #include "deMath.h"
     27 #include "tcuDefs.hpp"
     28 #include "tcuTestLog.hpp"
     29 
     30 #include <vector>
     31 
     32 namespace deqp
     33 {
     34 namespace gls
     35 {
     36 namespace RasterizationTestUtil
     37 {
     38 
     39 enum CoverageType
     40 {
     41 	COVERAGE_FULL = 0,		// !< primitive fully covers the queried area
     42 	COVERAGE_PARTIAL,		// !< primitive coverage is either partial, or could be full, partial or none depending on rounding and/or fill rules
     43 	COVERAGE_NONE,			// !< primitive does not cover area at all
     44 
     45 	COVERAGE_LAST
     46 };
     47 
     48 enum VerificationMode
     49 {
     50 	VERIFICATIONMODE_STRICT = 0,	// !< do not allow even a single bad pixel
     51 	VERIFICATIONMODE_WEAK,			// !< allow some bad pixels
     52 
     53 	VERIFICATIONMODE_LAST
     54 };
     55 
     56 struct TriangleSceneSpec
     57 {
     58 	struct SceneTriangle
     59 	{
     60 		tcu::Vec4	positions[3];
     61 		tcu::Vec4	colors[3];
     62 		bool		sharedEdge[3]; // !< is the edge i -> i+1 shared with another scene triangle
     63 	};
     64 
     65 	std::vector<SceneTriangle> triangles;
     66 };
     67 
     68 struct LineSceneSpec
     69 {
     70 	struct SceneLine
     71 	{
     72 		tcu::Vec4	positions[2];
     73 		tcu::Vec4	colors[2];
     74 	};
     75 
     76 	std::vector<SceneLine>	lines;
     77 	float					lineWidth;
     78 };
     79 
     80 struct PointSceneSpec
     81 {
     82 	struct ScenePoint
     83 	{
     84 		tcu::Vec4	position;
     85 		tcu::Vec4	color;
     86 		float		pointSize;
     87 	};
     88 
     89 	std::vector<ScenePoint> points;
     90 };
     91 
     92 struct RasterizationArguments
     93 {
     94 	int numSamples;
     95 	int subpixelBits;
     96 	int redBits;
     97 	int greenBits;
     98 	int blueBits;
     99 };
    100 
    101 /*--------------------------------------------------------------------*//*!
    102  * \brief Calculates triangle coverage at given pixel
    103  * Calculates the coverage of a triangle given by three vertices. The
    104  * triangle should not be z-clipped. If multisample is false, the pixel
    105  * center is compared against the triangle. If multisample is true, the
    106  * whole pixel area is compared.
    107  *//*--------------------------------------------------------------------*/
    108 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);
    109 
    110 /*--------------------------------------------------------------------*//*!
    111  * \brief Verify triangle rasterization result
    112  * Verifies pixels in the surface are rasterized within the bounds given
    113  * by RasterizationArguments. Triangles should not be z-clipped.
    114  *
    115  * Triangle colors are not used. The triangle is expected to be white.
    116  *
    117  * Returns false if invalid rasterization is found.
    118  *//*--------------------------------------------------------------------*/
    119 bool verifyTriangleGroupRasterization (const tcu::Surface& surface, const TriangleSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log, VerificationMode mode = VERIFICATIONMODE_STRICT);
    120 
    121 /*--------------------------------------------------------------------*//*!
    122  * \brief Verify line rasterization result
    123  * Verifies pixels in the surface are rasterized within the bounds given
    124  * by RasterizationArguments. Lines should not be z-clipped.
    125  *
    126  * Line colors are not used. The line is expected to be white.
    127  *
    128  * Returns false if invalid rasterization is found.
    129  *//*--------------------------------------------------------------------*/
    130 bool verifyLineGroupRasterization (const tcu::Surface& surface, const LineSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
    131 
    132 /*--------------------------------------------------------------------*//*!
    133  * \brief Verify point rasterization result
    134  * Verifies points in the surface are rasterized within the bounds given
    135  * by RasterizationArguments. Points should not be z-clipped.
    136  *
    137  * Point colors are not used. The point is expected to be white.
    138  *
    139  * Returns false if invalid rasterization is found.
    140  *//*--------------------------------------------------------------------*/
    141 bool verifyPointGroupRasterization (const tcu::Surface& surface, const PointSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
    142 
    143 /*--------------------------------------------------------------------*//*!
    144  * \brief Verify triangle color interpolation is valid
    145  * Verifies the color of a fragments of a colored triangle is in the
    146  * valid range. Triangles should not be z-clipped.
    147  *
    148  * The background is expected to be black.
    149  *
    150  * Returns false if invalid rasterization interpolation is found.
    151  *//*--------------------------------------------------------------------*/
    152 bool verifyTriangleGroupInterpolation (const tcu::Surface& surface, const TriangleSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
    153 
    154 /*--------------------------------------------------------------------*//*!
    155  * \brief Verify line color interpolation is valid
    156  * Verifies the color of a fragments of a colored line is in the
    157  * valid range. Lines should not be z-clipped.
    158  *
    159  * The background is expected to be black.
    160  *
    161  * Returns false if invalid rasterization interpolation is found.
    162  *//*--------------------------------------------------------------------*/
    163 bool verifyLineGroupInterpolation (const tcu::Surface& surface, const LineSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
    164 
    165 } // StateQueryUtil
    166 } // gls
    167 } // deqp
    168 
    169 #endif // _GLSRASTERIZATIONTESTUTIL_HPP
    170