1 #ifndef _GLSRASTERIZATIONTESTUTIL_HPP
2 #define _GLSRASTERIZATIONTESTUTIL_HPP
3 /*-------------------------------------------------------------------------
4 * drawElements Quality Program OpenGL (ES) Module
5 * -----------------------------------------------
7 * Copyright 2014 The Android Open Source Project
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 * \brief rasterization test utils.
24 *//*--------------------------------------------------------------------*/
27 #include "tcuDefs.hpp"
28 #include "tcuTestLog.hpp"
36 namespace RasterizationTestUtil
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
50 VERIFICATIONMODE_STRICT = 0, // !< do not allow even a single bad pixel
51 VERIFICATIONMODE_WEAK, // !< allow some bad pixels
56 enum LineInterpolationMethod
58 LINEINTERPOLATION_STRICTLY_CORRECT = 0, // !< line interpolation matches the specification
59 LINEINTERPOLATION_PROJECTED, // !< line interpolation weights are otherwise correct, but they are projected onto major axis
60 LINEINTERPOLATION_INCORRECT // !< line interpolation is incorrect
63 struct TriangleSceneSpec
67 tcu::Vec4 positions[3];
69 bool sharedEdge[3]; // !< is the edge i -> i+1 shared with another scene triangle
72 std::vector<SceneTriangle> triangles;
79 tcu::Vec4 positions[2];
83 std::vector<SceneLine> lines;
96 std::vector<ScenePoint> points;
99 struct RasterizationArguments
108 /*--------------------------------------------------------------------*//*!
109 * \brief Calculates triangle coverage at given pixel
110 * Calculates the coverage of a triangle given by three vertices. The
111 * triangle should not be z-clipped. If multisample is false, the pixel
112 * center is compared against the triangle. If multisample is true, the
113 * whole pixel area is compared.
114 *//*--------------------------------------------------------------------*/
115 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);
117 /*--------------------------------------------------------------------*//*!
118 * \brief Verify triangle rasterization result
119 * Verifies pixels in the surface are rasterized within the bounds given
120 * by RasterizationArguments. Triangles should not be z-clipped.
122 * Triangle colors are not used. The triangle is expected to be white.
124 * Returns false if invalid rasterization is found.
125 *//*--------------------------------------------------------------------*/
126 bool verifyTriangleGroupRasterization (const tcu::Surface& surface, const TriangleSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log, VerificationMode mode = VERIFICATIONMODE_STRICT);
128 /*--------------------------------------------------------------------*//*!
129 * \brief Verify line rasterization result
130 * Verifies pixels in the surface are rasterized within the bounds given
131 * by RasterizationArguments. Lines should not be z-clipped.
133 * Line colors are not used. The line is expected to be white.
135 * Returns false if invalid rasterization is found.
136 *//*--------------------------------------------------------------------*/
137 bool verifyLineGroupRasterization (const tcu::Surface& surface, const LineSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
139 /*--------------------------------------------------------------------*//*!
140 * \brief Verify point rasterization result
141 * Verifies points in the surface are rasterized within the bounds given
142 * by RasterizationArguments. Points should not be z-clipped.
144 * Point colors are not used. The point is expected to be white.
146 * Returns false if invalid rasterization is found.
147 *//*--------------------------------------------------------------------*/
148 bool verifyPointGroupRasterization (const tcu::Surface& surface, const PointSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
150 /*--------------------------------------------------------------------*//*!
151 * \brief Verify triangle color interpolation is valid
152 * Verifies the color of a fragments of a colored triangle is in the
153 * valid range. Triangles should not be z-clipped.
155 * The background is expected to be black.
157 * Returns false if invalid rasterization interpolation is found.
158 *//*--------------------------------------------------------------------*/
159 bool verifyTriangleGroupInterpolation (const tcu::Surface& surface, const TriangleSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
161 /*--------------------------------------------------------------------*//*!
162 * \brief Verify line color interpolation is valid
163 * Verifies the color of a fragments of a colored line is in the
164 * valid range. Lines should not be z-clipped.
166 * The background is expected to be black.
168 * Returns the detected interpolation method of the input image.
169 *//*--------------------------------------------------------------------*/
170 LineInterpolationMethod verifyLineGroupInterpolation (const tcu::Surface& surface, const LineSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
176 #endif // _GLSRASTERIZATIONTESTUTIL_HPP