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"
28 #include "tcuSurface.hpp"
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
47 VERIFICATIONMODE_STRICT = 0, // !< do not allow even a single bad pixel
48 VERIFICATIONMODE_WEAK, // !< allow some bad pixels
53 enum LineInterpolationMethod
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
60 struct TriangleSceneSpec
64 tcu::Vec4 positions[3];
66 bool sharedEdge[3]; // !< is the edge i -> i+1 shared with another scene triangle
69 std::vector<SceneTriangle> triangles;
76 tcu::Vec4 positions[2];
80 std::vector<SceneLine> lines;
93 std::vector<ScenePoint> points;
96 struct RasterizationArguments
105 struct VerifyTriangleGroupRasterizationLogStash
108 int unexpectedPixels;
109 tcu::Surface errorMask;
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);
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.
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.
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);
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.
139 * Line colors are not used. The line is expected to be white.
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);
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.
151 * Line colors are not used. The line is expected to be white. Lines are
152 * rasterized as two triangles.
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);
158 /*--------------------------------------------------------------------*//*!
159 * \brief Verify line rasterization result both clipped and non-clipped
161 * For details please see verifyLineGroupRasterization and
162 * verifyClippedTriangulatedLineGroupRasterization
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);
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.
173 * Point colors are not used. The point is expected to be white.
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);
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.
184 * The background is expected to be black.
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);
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.
195 * The background is expected to be black.
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);
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.
206 * The background is expected to be black. The lines are rasterized
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);
215 #endif // _TCURASTERIZATIONVERIFIER_HPP