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
49 VERIFICATIONMODE_WEAKER, // !< allow more bad pixels
50 VERIFICATIONMODE_SMOOTH, // !< allow no missing pixels
55 enum LineInterpolationMethod
57 LINEINTERPOLATION_STRICTLY_CORRECT = 0, // !< line interpolation matches the specification
58 LINEINTERPOLATION_PROJECTED, // !< line interpolation weights are otherwise correct, but they are projected onto major axis
59 LINEINTERPOLATION_INCORRECT // !< line interpolation is incorrect
62 struct TriangleSceneSpec
66 tcu::Vec4 positions[3];
68 bool sharedEdge[3]; // !< is the edge i -> i+1 shared with another scene triangle
71 std::vector<SceneTriangle> triangles;
79 , isRectangular(false)
80 , stippleEnable(false)
81 , verificationMode(VERIFICATIONMODE_STRICT)
86 tcu::Vec4 positions[2];
90 std::vector<SceneLine> lines;
95 bool allowNonProjectedInterpolation;
97 deUint32 stippleFactor;
98 deUint16 stipplePattern;
99 VerificationMode verificationMode;
102 struct PointSceneSpec
111 std::vector<ScenePoint> points;
114 struct RasterizationArguments
123 struct VerifyTriangleGroupRasterizationLogStash
125 std::vector<std::string> messages;
127 int unexpectedPixels;
128 tcu::Surface errorMask;
132 struct VerifyTriangleGroupInterpolationLogStash
134 std::vector<std::string> messages;
136 tcu::Surface errorMask;
140 /*--------------------------------------------------------------------*//*!
141 * \brief Calculates triangle coverage at given pixel
142 * Calculates the coverage of a triangle given by three vertices. The
143 * triangle should not be z-clipped. If multisample is false, the pixel
144 * center is compared against the triangle. If multisample is true, the
145 * whole pixel area is compared.
146 *//*--------------------------------------------------------------------*/
147 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);
149 /*--------------------------------------------------------------------*//*!
150 * \brief Calculates line coverage at given pixel
151 * Calculates the coverage of a reactangle given by line coordinates and width.
152 *//*--------------------------------------------------------------------*/
153 CoverageType calculateUnderestimateLineCoverage (const tcu::Vec4& p0, const tcu::Vec4& p1, const float lineWidth, const tcu::IVec2& pixel, const tcu::IVec2& viewportSize);
155 /*--------------------------------------------------------------------*//*!
156 * \brief Calculates triangle coverage at given pixel
157 * Calculates the coverage of a triangle given by by three vertices.
158 *//*--------------------------------------------------------------------*/
159 CoverageType calculateUnderestimateTriangleCoverage (const tcu::Vec4& p0, const tcu::Vec4& p1, const tcu::Vec4& p2, const tcu::IVec2& pixel, int subpixelBits, const tcu::IVec2& viewportSize);
161 /*--------------------------------------------------------------------*//*!
162 * \brief Verify triangle rasterization result
163 * Verifies pixels in the surface are rasterized within the bounds given
164 * by RasterizationArguments. Triangles should not be z-clipped.
166 * Triangle colors are not used. The triangle is expected to be white.
167 * If logStash is not NULL the results are not logged, but copied to stash.
169 * Returns false if invalid rasterization is found.
170 *//*--------------------------------------------------------------------*/
171 bool verifyTriangleGroupRasterization (const tcu::Surface& surface, const TriangleSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log, VerificationMode mode = VERIFICATIONMODE_STRICT, VerifyTriangleGroupRasterizationLogStash* logStash = DE_NULL, const bool vulkanLinesTest = false);
173 /*--------------------------------------------------------------------*//*!
174 * \brief Verify line rasterization result
175 * Verifies pixels in the surface are rasterized within the bounds given
176 * by RasterizationArguments. Lines should not be z-clipped.
178 * Line colors are not used. The line is expected to be white.
180 * Returns false if invalid rasterization is found.
181 *//*--------------------------------------------------------------------*/
182 bool verifyLineGroupRasterization (const tcu::Surface& surface, const LineSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
184 /*--------------------------------------------------------------------*//*!
185 * \brief Verify clipped line rasterization result
186 * Verifies pixels in the surface are rasterized within the bounds given
187 * by RasterizationArguments and by clipping the lines with a (-1, -1), (1, 1)
188 * square. Lines should not be z-clipped.
190 * Line colors are not used. The line is expected to be white. Lines are
191 * rasterized as two triangles.
193 * Returns false if invalid rasterization is found.
194 *//*--------------------------------------------------------------------*/
195 bool verifyClippedTriangulatedLineGroupRasterization (const tcu::Surface& surface, const LineSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
197 /*--------------------------------------------------------------------*//*!
198 * \brief Verify line rasterization result both clipped and non-clipped
200 * For details please see verifyLineGroupRasterization and
201 * verifyClippedTriangulatedLineGroupRasterization
203 * Returns false if both rasterizations are invalid.
204 *//*--------------------------------------------------------------------*/
205 bool verifyRelaxedLineGroupRasterization (const tcu::Surface& surface, const LineSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log, const bool vulkanLinesTest = false, const bool strict = true);
207 /*--------------------------------------------------------------------*//*!
208 * \brief Verify point rasterization result
209 * Verifies points in the surface are rasterized within the bounds given
210 * by RasterizationArguments. Points should not be z-clipped.
212 * Point colors are not used. The point is expected to be white.
214 * Returns false if invalid rasterization is found.
215 *//*--------------------------------------------------------------------*/
216 bool verifyPointGroupRasterization (const tcu::Surface& surface, const PointSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
218 /*--------------------------------------------------------------------*//*!
219 * \brief Verify triangle color interpolation is valid
220 * Verifies the color of a fragments of a colored triangle is in the
221 * valid range. Triangles should not be z-clipped.
223 * The background is expected to be black.
225 * Returns false if invalid rasterization interpolation is found.
226 *//*--------------------------------------------------------------------*/
227 bool verifyTriangleGroupInterpolation (const tcu::Surface& surface, const TriangleSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
229 /*--------------------------------------------------------------------*//*!
230 * \brief Verify line color interpolation is valid
231 * Verifies the color of a fragments of a colored line is in the
232 * valid range. Lines should not be z-clipped.
234 * The background is expected to be black.
236 * Returns the detected interpolation method of the input image.
237 *//*--------------------------------------------------------------------*/
238 LineInterpolationMethod verifyLineGroupInterpolation (const tcu::Surface& surface, const LineSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
240 /*--------------------------------------------------------------------*//*!
241 * \brief Verify line color interpolation is valid
242 * Verifies the color of a fragments of a colored line is in the
243 * valid range. Lines should not be z-clipped.
245 * The background is expected to be black. The lines are rasterized
248 * Returns false if invalid rasterization interpolation is found.
249 *//*--------------------------------------------------------------------*/
250 bool verifyTriangulatedLineGroupInterpolation (const tcu::Surface& surface, const LineSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log, const bool strictMode = true, const bool allowBresenhamForNonStrictLines = false);
254 #endif // _TCURASTERIZATIONVERIFIER_HPP