blob: af86283df0ec91163afb10fe7a80580646bb96f9 [file] [log] [blame]
Jarkko Poyry3c827362014-09-02 11:48:52 +03001#ifndef _GLSRASTERIZATIONTESTUTIL_HPP
2#define _GLSRASTERIZATIONTESTUTIL_HPP
3/*-------------------------------------------------------------------------
4 * drawElements Quality Program OpenGL (ES) Module
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 test utils.
24 *//*--------------------------------------------------------------------*/
25
26#include "deMath.h"
27#include "tcuDefs.hpp"
28#include "tcuTestLog.hpp"
29
30#include <vector>
31
32namespace deqp
33{
34namespace gls
35{
36namespace RasterizationTestUtil
37{
38
39enum CoverageType
40{
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
44
45 COVERAGE_LAST
46};
47
48enum VerificationMode
49{
50 VERIFICATIONMODE_STRICT = 0, // !< do not allow even a single bad pixel
51 VERIFICATIONMODE_WEAK, // !< allow some bad pixels
52
53 VERIFICATIONMODE_LAST
54};
55
Jarkko Pöyry2306a3b2015-02-19 19:40:03 -080056enum LineInterpolationMethod
57{
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
61};
62
Jarkko Poyry3c827362014-09-02 11:48:52 +030063struct TriangleSceneSpec
64{
65 struct SceneTriangle
66 {
67 tcu::Vec4 positions[3];
68 tcu::Vec4 colors[3];
69 bool sharedEdge[3]; // !< is the edge i -> i+1 shared with another scene triangle
70 };
71
72 std::vector<SceneTriangle> triangles;
73};
74
75struct LineSceneSpec
76{
77 struct SceneLine
78 {
79 tcu::Vec4 positions[2];
80 tcu::Vec4 colors[2];
81 };
82
83 std::vector<SceneLine> lines;
84 float lineWidth;
85};
86
87struct PointSceneSpec
88{
89 struct ScenePoint
90 {
91 tcu::Vec4 position;
92 tcu::Vec4 color;
93 float pointSize;
94 };
95
96 std::vector<ScenePoint> points;
97};
98
99struct RasterizationArguments
100{
101 int numSamples;
102 int subpixelBits;
103 int redBits;
104 int greenBits;
105 int blueBits;
106};
107
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 *//*--------------------------------------------------------------------*/
115CoverageType 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);
116
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.
121 *
122 * Triangle colors are not used. The triangle is expected to be white.
123 *
124 * Returns false if invalid rasterization is found.
125 *//*--------------------------------------------------------------------*/
126bool verifyTriangleGroupRasterization (const tcu::Surface& surface, const TriangleSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log, VerificationMode mode = VERIFICATIONMODE_STRICT);
127
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.
132 *
133 * Line colors are not used. The line is expected to be white.
134 *
135 * Returns false if invalid rasterization is found.
136 *//*--------------------------------------------------------------------*/
137bool verifyLineGroupRasterization (const tcu::Surface& surface, const LineSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
138
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.
143 *
144 * Point colors are not used. The point is expected to be white.
145 *
146 * Returns false if invalid rasterization is found.
147 *//*--------------------------------------------------------------------*/
148bool verifyPointGroupRasterization (const tcu::Surface& surface, const PointSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
149
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.
154 *
155 * The background is expected to be black.
156 *
157 * Returns false if invalid rasterization interpolation is found.
158 *//*--------------------------------------------------------------------*/
159bool verifyTriangleGroupInterpolation (const tcu::Surface& surface, const TriangleSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
160
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.
165 *
166 * The background is expected to be black.
167 *
Jarkko Pöyry2306a3b2015-02-19 19:40:03 -0800168 * Returns the detected interpolation method of the input image.
Jarkko Poyry3c827362014-09-02 11:48:52 +0300169 *//*--------------------------------------------------------------------*/
Jarkko Pöyry2306a3b2015-02-19 19:40:03 -0800170LineInterpolationMethod verifyLineGroupInterpolation (const tcu::Surface& surface, const LineSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
Jarkko Poyry3c827362014-09-02 11:48:52 +0300171
172} // StateQueryUtil
173} // gls
174} // deqp
175
176#endif // _GLSRASTERIZATIONTESTUTIL_HPP