1 #ifndef _TCURASTERIZATIONVERIFIER_HPP
2 #define _TCURASTERIZATIONVERIFIER_HPP
3 /*-------------------------------------------------------------------------
4 * drawElements Quality Program Tester Core
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 verifier utils.
24 *//*--------------------------------------------------------------------*/
26 #include "tcuDefs.hpp"
27 #include "tcuTestLog.hpp"
37 COVERAGE_FULL = 0, // !< primitive fully covers the queried area
38 COVERAGE_PARTIAL, // !< primitive coverage is either partial, or could be full, partial or none depending on rounding and/or fill rules
39 COVERAGE_NONE, // !< primitive does not cover area at all
46 VERIFICATIONMODE_STRICT = 0, // !< do not allow even a single bad pixel
47 VERIFICATIONMODE_WEAK, // !< allow some bad pixels
52 enum LineInterpolationMethod
54 LINEINTERPOLATION_STRICTLY_CORRECT = 0, // !< line interpolation matches the specification
55 LINEINTERPOLATION_PROJECTED, // !< line interpolation weights are otherwise correct, but they are projected onto major axis
56 LINEINTERPOLATION_INCORRECT // !< line interpolation is incorrect
59 struct TriangleSceneSpec
63 tcu::Vec4 positions[3];
65 bool sharedEdge[3]; // !< is the edge i -> i+1 shared with another scene triangle
68 std::vector<SceneTriangle> triangles;
75 tcu::Vec4 positions[2];
79 std::vector<SceneLine> lines;
92 std::vector<ScenePoint> points;
95 struct RasterizationArguments
104 /*--------------------------------------------------------------------*//*!
105 * \brief Calculates triangle coverage at given pixel
106 * Calculates the coverage of a triangle given by three vertices. The
107 * triangle should not be z-clipped. If multisample is false, the pixel
108 * center is compared against the triangle. If multisample is true, the
109 * whole pixel area is compared.
110 *//*--------------------------------------------------------------------*/
111 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);
113 /*--------------------------------------------------------------------*//*!
114 * \brief Verify triangle rasterization result
115 * Verifies pixels in the surface are rasterized within the bounds given
116 * by RasterizationArguments. Triangles should not be z-clipped.
118 * Triangle colors are not used. The triangle is expected to be white.
120 * Returns false if invalid rasterization is found.
121 *//*--------------------------------------------------------------------*/
122 bool verifyTriangleGroupRasterization (const tcu::Surface& surface, const TriangleSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log, VerificationMode mode = VERIFICATIONMODE_STRICT);
124 /*--------------------------------------------------------------------*//*!
125 * \brief Verify line rasterization result
126 * Verifies pixels in the surface are rasterized within the bounds given
127 * by RasterizationArguments. Lines should not be z-clipped.
129 * Line colors are not used. The line is expected to be white.
131 * Returns false if invalid rasterization is found.
132 *//*--------------------------------------------------------------------*/
133 bool verifyLineGroupRasterization (const tcu::Surface& surface, const LineSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
135 /*--------------------------------------------------------------------*//*!
136 * \brief Verify clipped line rasterization result
137 * Verifies pixels in the surface are rasterized within the bounds given
138 * by RasterizationArguments and by clipping the lines with a (-1, -1), (1, 1)
139 * square. Lines should not be z-clipped.
141 * Line colors are not used. The line is expected to be white. Lines are
142 * rasterized as two triangles.
144 * Returns false if invalid rasterization is found.
145 *//*--------------------------------------------------------------------*/
146 bool verifyClippedTriangulatedLineGroupRasterization (const tcu::Surface& surface, const LineSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
148 /*--------------------------------------------------------------------*//*!
149 * \brief Verify point rasterization result
150 * Verifies points in the surface are rasterized within the bounds given
151 * by RasterizationArguments. Points should not be z-clipped.
153 * Point colors are not used. The point is expected to be white.
155 * Returns false if invalid rasterization is found.
156 *//*--------------------------------------------------------------------*/
157 bool verifyPointGroupRasterization (const tcu::Surface& surface, const PointSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
159 /*--------------------------------------------------------------------*//*!
160 * \brief Verify triangle color interpolation is valid
161 * Verifies the color of a fragments of a colored triangle is in the
162 * valid range. Triangles should not be z-clipped.
164 * The background is expected to be black.
166 * Returns false if invalid rasterization interpolation is found.
167 *//*--------------------------------------------------------------------*/
168 bool verifyTriangleGroupInterpolation (const tcu::Surface& surface, const TriangleSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
170 /*--------------------------------------------------------------------*//*!
171 * \brief Verify line color interpolation is valid
172 * Verifies the color of a fragments of a colored line is in the
173 * valid range. Lines should not be z-clipped.
175 * The background is expected to be black.
177 * Returns the detected interpolation method of the input image.
178 *//*--------------------------------------------------------------------*/
179 LineInterpolationMethod verifyLineGroupInterpolation (const tcu::Surface& surface, const LineSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
181 /*--------------------------------------------------------------------*//*!
182 * \brief Verify line color interpolation is valid
183 * Verifies the color of a fragments of a colored line is in the
184 * valid range. Lines should not be z-clipped.
186 * The background is expected to be black. The lines are rasterized
189 * Returns false if invalid rasterization interpolation is found.
190 *//*--------------------------------------------------------------------*/
191 bool verifyTriangulatedLineGroupInterpolation (const tcu::Surface& surface, const LineSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
195 #endif // _TCURASTERIZATIONVERIFIER_HPP