13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef _GLSRASTERIZATIONTESTUTIL_HPP
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define _GLSRASTERIZATIONTESTUTIL_HPP
33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL (ES) Module
53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * -----------------------------------------------
63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project
83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License");
103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License.
113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at
123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *      http://www.apache.org/licenses/LICENSE-2.0
143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software
163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS,
173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and
193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License.
203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*!
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief rasterization test utils.
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deMath.h"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuDefs.hpp"
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp"
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <vector>
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gls
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace RasterizationTestUtil
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum CoverageType
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	COVERAGE_FULL = 0,		// !< primitive fully covers the queried area
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	COVERAGE_PARTIAL,		// !< primitive coverage is either partial, or could be full, partial or none depending on rounding and/or fill rules
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	COVERAGE_NONE,			// !< primitive does not cover area at all
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	COVERAGE_LAST
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum VerificationMode
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VERIFICATIONMODE_STRICT = 0,	// !< do not allow even a single bad pixel
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VERIFICATIONMODE_WEAK,			// !< allow some bad pixels
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VERIFICATIONMODE_LAST
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
562306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyryenum LineInterpolationMethod
572306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry{
582306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry	LINEINTERPOLATION_STRICTLY_CORRECT = 0,	// !< line interpolation matches the specification
592306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry	LINEINTERPOLATION_PROJECTED,			// !< line interpolation weights are otherwise correct, but they are projected onto major axis
602306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry	LINEINTERPOLATION_INCORRECT				// !< line interpolation is incorrect
612306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry};
622306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct TriangleSceneSpec
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	struct SceneTriangle
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::Vec4	positions[3];
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::Vec4	colors[3];
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool		sharedEdge[3]; // !< is the edge i -> i+1 shared with another scene triangle
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<SceneTriangle> triangles;
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct LineSceneSpec
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	struct SceneLine
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::Vec4	positions[2];
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::Vec4	colors[2];
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<SceneLine>	lines;
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float					lineWidth;
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct PointSceneSpec
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	struct ScenePoint
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::Vec4	position;
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::Vec4	color;
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		float		pointSize;
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<ScenePoint> points;
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct RasterizationArguments
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int numSamples;
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int subpixelBits;
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int redBits;
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int greenBits;
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int blueBits;
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Calculates triangle coverage at given pixel
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Calculates the coverage of a triangle given by three vertices. The
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * triangle should not be z-clipped. If multisample is false, the pixel
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * center is compared against the triangle. If multisample is true, the
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * whole pixel area is compared.
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
1153c827367444ee418f129b2c238299f49d3264554Jarkko PoyryCoverageType 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);
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Verify triangle rasterization result
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Verifies pixels in the surface are rasterized within the bounds given
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * by RasterizationArguments. Triangles should not be z-clipped.
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Triangle colors are not used. The triangle is expected to be white.
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Returns false if invalid rasterization is found.
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool verifyTriangleGroupRasterization (const tcu::Surface& surface, const TriangleSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log, VerificationMode mode = VERIFICATIONMODE_STRICT);
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Verify line rasterization result
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Verifies pixels in the surface are rasterized within the bounds given
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * by RasterizationArguments. Lines should not be z-clipped.
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Line colors are not used. The line is expected to be white.
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Returns false if invalid rasterization is found.
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool verifyLineGroupRasterization (const tcu::Surface& surface, const LineSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Verify point rasterization result
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Verifies points in the surface are rasterized within the bounds given
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * by RasterizationArguments. Points should not be z-clipped.
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Point colors are not used. The point is expected to be white.
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Returns false if invalid rasterization is found.
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool verifyPointGroupRasterization (const tcu::Surface& surface, const PointSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Verify triangle color interpolation is valid
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Verifies the color of a fragments of a colored triangle is in the
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * valid range. Triangles should not be z-clipped.
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * The background is expected to be black.
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Returns false if invalid rasterization interpolation is found.
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool verifyTriangleGroupInterpolation (const tcu::Surface& surface, const TriangleSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Verify line color interpolation is valid
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Verifies the color of a fragments of a colored line is in the
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * valid range. Lines should not be z-clipped.
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * The background is expected to be black.
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
1682306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry * Returns the detected interpolation method of the input image.
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
1702306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko PöyryLineInterpolationMethod verifyLineGroupInterpolation (const tcu::Surface& surface, const LineSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // StateQueryUtil
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gls
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _GLSRASTERIZATIONTESTUTIL_HPP
177