Add support for EGL_EXT_pixel_format_float am: 521bf8a7c3 am: 4b7baeace7 am: 86683f95...
[platform/upstream/VK-GL-CTS.git] / framework / common / tcuRasterizationVerifier.hpp
1 #ifndef _TCURASTERIZATIONVERIFIER_HPP
2 #define _TCURASTERIZATIONVERIFIER_HPP
3 /*-------------------------------------------------------------------------
4  * drawElements Quality Program Tester Core
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 verifier utils.
24  *//*--------------------------------------------------------------------*/
25
26 #include "tcuDefs.hpp"
27 #include "tcuTestLog.hpp"
28 #include "deMath.h"
29
30 #include <vector>
31
32 namespace tcu
33 {
34
35 enum CoverageType
36 {
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
40
41         COVERAGE_LAST
42 };
43
44 enum VerificationMode
45 {
46         VERIFICATIONMODE_STRICT = 0,    // !< do not allow even a single bad pixel
47         VERIFICATIONMODE_WEAK,                  // !< allow some bad pixels
48
49         VERIFICATIONMODE_LAST
50 };
51
52 enum LineInterpolationMethod
53 {
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
57 };
58
59 struct TriangleSceneSpec
60 {
61         struct SceneTriangle
62         {
63                 tcu::Vec4       positions[3];
64                 tcu::Vec4       colors[3];
65                 bool            sharedEdge[3]; // !< is the edge i -> i+1 shared with another scene triangle
66         };
67
68         std::vector<SceneTriangle> triangles;
69 };
70
71 struct LineSceneSpec
72 {
73         struct SceneLine
74         {
75                 tcu::Vec4       positions[2];
76                 tcu::Vec4       colors[2];
77         };
78
79         std::vector<SceneLine>  lines;
80         float                                   lineWidth;
81 };
82
83 struct PointSceneSpec
84 {
85         struct ScenePoint
86         {
87                 tcu::Vec4       position;
88                 tcu::Vec4       color;
89                 float           pointSize;
90         };
91
92         std::vector<ScenePoint> points;
93 };
94
95 struct RasterizationArguments
96 {
97         int numSamples;
98         int subpixelBits;
99         int redBits;
100         int greenBits;
101         int blueBits;
102 };
103
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);
112
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.
117  *
118  * Triangle colors are not used. The triangle is expected to be white.
119  *
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);
123
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.
128  *
129  * Line colors are not used. The line is expected to be white.
130  *
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);
134
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.
140  *
141  * Line colors are not used. The line is expected to be white. Lines are
142  * rasterized as two triangles.
143  *
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);
147
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.
152  *
153  * Point colors are not used. The point is expected to be white.
154  *
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);
158
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.
163  *
164  * The background is expected to be black.
165  *
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);
169
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.
174  *
175  * The background is expected to be black.
176  *
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);
180
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.
185  *
186  * The background is expected to be black. The lines are rasterized
187  * as two triangles.
188  *
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);
192
193 } // tcu
194
195 #endif // _TCURASTERIZATIONVERIFIER_HPP