glsRasterizationTestUtil.hpp revision 3c827367444ee418f129b2c238299f49d3264554
13ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#ifndef _GLSRASTERIZATIONTESTUTIL_HPP
23ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define _GLSRASTERIZATIONTESTUTIL_HPP
33ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*-------------------------------------------------------------------------
43ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * drawElements Quality Program OpenGL (ES) Module
53ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * -----------------------------------------------
63ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *
73ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * Copyright 2014 The Android Open Source Project
83ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *
93ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * Licensed under the Apache License, Version 2.0 (the "License");
103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * you may not use this file except in compliance with the License.
113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * You may obtain a copy of the License at
123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *
133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *      http://www.apache.org/licenses/LICENSE-2.0
143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *
153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * Unless required by applicable law or agreed to in writing, software
163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * distributed under the License is distributed on an "AS IS" BASIS,
173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * See the License for the specific language governing permissions and
19b56bb24a985ca4366713bcd8ffdfacbb48a98a2fcristy * limitations under the License.
203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *
213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *//*!
223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * \file
233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * \brief rasterization test utils.
243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *//*--------------------------------------------------------------------*/
253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#include "deMath.h"
273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#include "tcuDefs.hpp"
283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#include "tcuTestLog.hpp"
293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#include <vector>
313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
323ed852eea50f9d4cd633efb8c2b054b8e33c253cristynamespace deqp
333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
343ed852eea50f9d4cd633efb8c2b054b8e33c253cristynamespace gls
353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
363ed852eea50f9d4cd633efb8c2b054b8e33c253cristynamespace RasterizationTestUtil
373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
393ed852eea50f9d4cd633efb8c2b054b8e33c253cristyenum CoverageType
403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
414c08aed51c5899665ade97263692328eea4af106cristy	COVERAGE_FULL = 0,		// !< primitive fully covers the queried area
424c08aed51c5899665ade97263692328eea4af106cristy	COVERAGE_PARTIAL,		// !< primitive coverage is either partial, or could be full, partial or none depending on rounding and/or fill rules
434c08aed51c5899665ade97263692328eea4af106cristy	COVERAGE_NONE,			// !< primitive does not cover area at all
444c08aed51c5899665ade97263692328eea4af106cristy
454c08aed51c5899665ade97263692328eea4af106cristy	COVERAGE_LAST
464c08aed51c5899665ade97263692328eea4af106cristy};
474c08aed51c5899665ade97263692328eea4af106cristy
484c08aed51c5899665ade97263692328eea4af106cristyenum VerificationMode
494c08aed51c5899665ade97263692328eea4af106cristy{
504c08aed51c5899665ade97263692328eea4af106cristy	VERIFICATIONMODE_STRICT = 0,	// !< do not allow even a single bad pixel
51c53413df5789700e14e1a67e6cc2716d1716a387cristy	VERIFICATIONMODE_WEAK,			// !< allow some bad pixels
524c08aed51c5899665ade97263692328eea4af106cristy
534c08aed51c5899665ade97263692328eea4af106cristy	VERIFICATIONMODE_LAST
544c08aed51c5899665ade97263692328eea4af106cristy};
554c08aed51c5899665ade97263692328eea4af106cristy
564c08aed51c5899665ade97263692328eea4af106cristystruct TriangleSceneSpec
574c08aed51c5899665ade97263692328eea4af106cristy{
584c08aed51c5899665ade97263692328eea4af106cristy	struct SceneTriangle
594c08aed51c5899665ade97263692328eea4af106cristy	{
604c08aed51c5899665ade97263692328eea4af106cristy		tcu::Vec4	positions[3];
614c08aed51c5899665ade97263692328eea4af106cristy		tcu::Vec4	colors[3];
624c08aed51c5899665ade97263692328eea4af106cristy		bool		sharedEdge[3]; // !< is the edge i -> i+1 shared with another scene triangle
634c08aed51c5899665ade97263692328eea4af106cristy	};
644c08aed51c5899665ade97263692328eea4af106cristy
654c08aed51c5899665ade97263692328eea4af106cristy	std::vector<SceneTriangle> triangles;
6618c6c27bc513a8c73a5bc4a2c157afb19c3e24b9cristy};
673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
683ed852eea50f9d4cd633efb8c2b054b8e33c253cristystruct LineSceneSpec
693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy	struct SceneLine
713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy	{
723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy		tcu::Vec4	positions[2];
733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy		tcu::Vec4	colors[2];
743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy	};
753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
764189984c711febcbd1a99f01663b62cadee43a5acristy	std::vector<SceneLine>	lines;
773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy	float					lineWidth;
783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy};
793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
803ed852eea50f9d4cd633efb8c2b054b8e33c253cristystruct PointSceneSpec
813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy	struct ScenePoint
833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy	{
843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy		tcu::Vec4	position;
853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy		tcu::Vec4	color;
863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy		float		pointSize;
873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy	};
883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy	std::vector<ScenePoint> points;
903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy};
913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
923ed852eea50f9d4cd633efb8c2b054b8e33c253cristystruct RasterizationArguments
933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy	int numSamples;
953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy	int subpixelBits;
963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy	int redBits;
973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy	int greenBits;
983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy	int blueBits;
993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy};
1003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*--------------------------------------------------------------------*//*!
1023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * \brief Calculates triangle coverage at given pixel
1033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * Calculates the coverage of a triangle given by three vertices. The
1043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * triangle should not be z-clipped. If multisample is false, the pixel
1053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * center is compared against the triangle. If multisample is true, the
1063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * whole pixel area is compared.
1073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *//*--------------------------------------------------------------------*/
1083ed852eea50f9d4cd633efb8c2b054b8e33c253cristyCoverageType 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);
1093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*--------------------------------------------------------------------*//*!
1113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * \brief Verify triangle rasterization result
1123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * Verifies pixels in the surface are rasterized within the bounds given
1133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * by RasterizationArguments. Triangles should not be z-clipped.
1143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *
1153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * Triangle colors are not used. The triangle is expected to be white.
1163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *
1173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * Returns false if invalid rasterization is found.
1183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *//*--------------------------------------------------------------------*/
1193ed852eea50f9d4cd633efb8c2b054b8e33c253cristybool verifyTriangleGroupRasterization (const tcu::Surface& surface, const TriangleSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log, VerificationMode mode = VERIFICATIONMODE_STRICT);
1203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*--------------------------------------------------------------------*//*!
1223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * \brief Verify line rasterization result
1233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * Verifies pixels in the surface are rasterized within the bounds given
1243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * by RasterizationArguments. Lines should not be z-clipped.
1253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *
1263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * Line colors are not used. The line is expected to be white.
1273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *
1283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * Returns false if invalid rasterization is found.
1293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *//*--------------------------------------------------------------------*/
1303ed852eea50f9d4cd633efb8c2b054b8e33c253cristybool verifyLineGroupRasterization (const tcu::Surface& surface, const LineSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
1313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*--------------------------------------------------------------------*//*!
1333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * \brief Verify point rasterization result
1343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * Verifies points in the surface are rasterized within the bounds given
1353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * by RasterizationArguments. Points should not be z-clipped.
1363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *
1373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * Point colors are not used. The point is expected to be white.
1383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *
1393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * Returns false if invalid rasterization is found.
1403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *//*--------------------------------------------------------------------*/
1413ed852eea50f9d4cd633efb8c2b054b8e33c253cristybool verifyPointGroupRasterization (const tcu::Surface& surface, const PointSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
1423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*--------------------------------------------------------------------*//*!
1443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * \brief Verify triangle color interpolation is valid
1453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * Verifies the color of a fragments of a colored triangle is in the
1463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * valid range. Triangles should not be z-clipped.
1473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *
1483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * The background is expected to be black.
1493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *
1503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * Returns false if invalid rasterization interpolation is found.
1513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *//*--------------------------------------------------------------------*/
1523ed852eea50f9d4cd633efb8c2b054b8e33c253cristybool verifyTriangleGroupInterpolation (const tcu::Surface& surface, const TriangleSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
1533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*--------------------------------------------------------------------*//*!
1553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * \brief Verify line color interpolation is valid
1563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * Verifies the color of a fragments of a colored line is in the
1573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * valid range. Lines should not be z-clipped.
1583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *
1593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * The background is expected to be black.
1603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *
1613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy * Returns false if invalid rasterization interpolation is found.
1623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *//*--------------------------------------------------------------------*/
1633ed852eea50f9d4cd633efb8c2b054b8e33c253cristybool verifyLineGroupInterpolation (const tcu::Surface& surface, const LineSceneSpec& scene, const RasterizationArguments& args, tcu::TestLog& log);
1643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} // StateQueryUtil
1663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} // gls
1673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} // deqp
1683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif // _GLSRASTERIZATIONTESTUTIL_HPP
1703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy