13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef _RRRASTERIZER_HPP
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define _RRRASTERIZER_HPP
33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program Reference Renderer
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 Reference rasterizer
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "rrDefs.hpp"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuVector.hpp"
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "rrRenderState.hpp"
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "rrFragmentPacket.hpp"
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace rr
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! Rasterizer configuration
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	RASTERIZER_SUBPIXEL_BITS			= 8,
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	RASTERIZER_MAX_SAMPLES_PER_FRAGMENT	= 16
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! Get coverage bit value.
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline deUint64 getCoverageBit (int numSamples, int x, int y, int sampleNdx)
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
45b0a384bf9b6816d4e3e594b37955d220d66ac7d1Jarkko Pöyry	const int	numBits		= (int)sizeof(deUint64)*8;
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int	maxSamples	= numBits/4;
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_STATIC_ASSERT(maxSamples >= RASTERIZER_MAX_SAMPLES_PER_FRAGMENT);
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(de::inRange(numSamples, 1, maxSamples) && de::inBounds(x, 0, 2) && de::inBounds(y, 0, 2));
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return 1ull << ((x*2 + y)*numSamples + sampleNdx);
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! Get all sample bits for fragment
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline deUint64 getCoverageFragmentSampleBits (int numSamples, int x, int y)
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(de::inBounds(x, 0, 2) && de::inBounds(y, 0, 2));
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint64 fragMask = (1ull << numSamples) - 1;
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return fragMask << (x*2 + y)*numSamples;
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! Set bit in coverage mask.
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline deUint64 setCoverageValue (deUint64 mask, int numSamples, int x, int y, int sampleNdx, bool val)
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint64 bit = getCoverageBit(numSamples, x, y, sampleNdx);
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return val ? (mask | bit) : (mask & ~bit);
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! Get coverage bit value in mask.
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline bool getCoverageValue (deUint64 mask, int numSamples, int x, int y, int sampleNdx)
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return (mask & getCoverageBit(numSamples, x, y, sampleNdx)) != 0;
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! Test if any sample for fragment is live
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline bool getCoverageAnyFragmentSampleLive (deUint64 mask, int numSamples, int x, int y)
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return (mask & getCoverageFragmentSampleBits(numSamples, x, y)) != 0;
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! Get position of first coverage bit of fragment - equivalent to deClz64(getCoverageFragmentSampleBits(numSamples, x, y)).
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline int getCoverageOffset (int numSamples, int x, int y)
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return (x*2 + y)*numSamples;
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Edge function
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Edge function can be evaluated for point P (in fixed-point coordinates
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * with SUBPIXEL_BITS fractional part) by computing
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  D = a*Px + b*Py + c
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * D will be fixed-point value where lower (SUBPIXEL_BITS*2) bits will
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * be fractional part.
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * a and b are stored with SUBPIXEL_BITS fractional part, while c is stored
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * with SUBPIXEL_BITS*2 fractional bits.
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct EdgeFunction
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	inline EdgeFunction (void) : a(0), b(0), c(0), inclusive(false) {}
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deInt64			a;
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deInt64			b;
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deInt64			c;
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool			inclusive;	//!< True if edge is inclusive according to fill rules.
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Triangle rasterizer
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Triangle rasterizer implements following features:
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  - Rasterization using fixed-point coordinates
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  - 1, 4, and 16 -sample rasterization
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  - Depth interpolation
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  - Perspective-correct barycentric computation for interpolation
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  - Visible face determination
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * It does not (and will not) implement following:
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  - Triangle setup
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  - Clipping
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  - Degenerate elimination
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  - Coordinate transformation (inputs are in screen-space)
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  - Culling - logic can be implemented outside by querying visible face
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  - Scissoring (this can be done by controlling viewport rectangle)
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  - Any per-fragment operations
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TriangleRasterizer
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							TriangleRasterizer		(const tcu::IVec4& viewport, const int numSamples, const RasterizationState& state);
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					init					(const tcu::Vec4& v0, const tcu::Vec4& v1, const tcu::Vec4& v2);
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Following functions are only available after init()
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FaceType				getVisibleFace			(void) const { return m_face; }
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					rasterize				(FragmentPacket* const fragmentPackets, float* const depthValues, const int maxFragmentPackets, int& numPacketsRasterized);
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					rasterizeSingleSample	(FragmentPacket* const fragmentPackets, float* const depthValues, const int maxFragmentPackets, int& numPacketsRasterized);
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	template<int NumSamples>
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					rasterizeMultiSample	(FragmentPacket* const fragmentPackets, float* const depthValues, const int maxFragmentPackets, int& numPacketsRasterized);
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Constant rasterization state.
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::IVec4		m_viewport;
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int				m_numSamples;
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const Winding			m_winding;
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const HorizontalFill	m_horizontalFill;
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const VerticalFill		m_verticalFill;
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Per-triangle rasterization state.
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Vec4				m_v0;
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Vec4				m_v1;
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Vec4				m_v2;
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	EdgeFunction			m_edge01;
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	EdgeFunction			m_edge12;
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	EdgeFunction			m_edge20;
1581409d3b197da7b68b13c2f5e15023f50b7078294David Sodman	FaceType				m_face;					//!< Triangle orientation, eg. visible face.
1591409d3b197da7b68b13c2f5e15023f50b7078294David Sodman	tcu::IVec2				m_bboxMin;				//!< Bounding box min (inclusive).
1601409d3b197da7b68b13c2f5e15023f50b7078294David Sodman	tcu::IVec2				m_bboxMax;				//!< Bounding box max (inclusive).
1611409d3b197da7b68b13c2f5e15023f50b7078294David Sodman	tcu::IVec2				m_curPos;				//!< Current rasterization position.
1621409d3b197da7b68b13c2f5e15023f50b7078294David Sodman	ViewportOrientation		m_viewportOrientation;	//!< Direction of +x+y axis
16393df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE;
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1652306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Single sample line rasterizer
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
1692306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry * Line rasterizer implements following features:
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  - Rasterization using fixed-point coordinates
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  - Depth interpolation
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  - Perspective-correct interpolation
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * It does not (and will not) implement following:
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  - Clipping
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  - Multisampled line rasterization
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass SingleSampleLineRasterizer
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									SingleSampleLineRasterizer	(const tcu::IVec4& viewport);
1822306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry									~SingleSampleLineRasterizer	(void);
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void							init						(const tcu::Vec4& v0, const tcu::Vec4& v1, float lineWidth);
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// only available after init()
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void							rasterize					(FragmentPacket* const fragmentPackets, float* const depthValues, const int maxFragmentPackets, int& numPacketsRasterized);
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									SingleSampleLineRasterizer	(const SingleSampleLineRasterizer&); // not allowed
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	SingleSampleLineRasterizer&		operator=					(const SingleSampleLineRasterizer&); // not allowed
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Constant rasterization state.
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::IVec4				m_viewport;
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Per-line rasterization state.
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Vec4						m_v0;
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Vec4						m_v1;
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::IVec2						m_bboxMin;			//!< Bounding box min (inclusive).
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::IVec2						m_bboxMax;			//!< Bounding box max (inclusive).
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::IVec2						m_curPos;			//!< Current rasterization position.
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deInt32							m_curRowFragment;	//!< Current rasterization position of one fragment in column of lineWidth fragments
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float							m_lineWidth;
20493df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE;
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Multisampled line rasterizer
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
2102306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry * Line rasterizer implements following features:
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  - Rasterization using fixed-point coordinates
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  - Depth interpolation
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  - Perspective-correct interpolation
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * It does not (and will not) implement following:
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  - Clipping
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  - Aliased line rasterization
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass MultiSampleLineRasterizer
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								MultiSampleLineRasterizer	(const int numSamples, const tcu::IVec4& viewport);
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								~MultiSampleLineRasterizer	();
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						init						(const tcu::Vec4& v0, const tcu::Vec4& v1, float lineWidth);
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// only available after init()
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						rasterize					(FragmentPacket* const fragmentPackets, float* const depthValues, const int maxFragmentPackets, int& numPacketsRasterized);
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								MultiSampleLineRasterizer	(const MultiSampleLineRasterizer&); // not allowed
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	MultiSampleLineRasterizer&	operator=					(const MultiSampleLineRasterizer&); // not allowed
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Constant rasterization state.
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int					m_numSamples;
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Per-line rasterization state.
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TriangleRasterizer			m_triangleRasterizer0; //!< not in array because we want to initialize these in the initialization list
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TriangleRasterizer			m_triangleRasterizer1;
24093df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE;
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2422306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry
2432306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry/*--------------------------------------------------------------------*//*!
2442306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry * \brief Pixel diamond
2452306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry *
2462306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry * Structure representing a diamond a line exits.
2472306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry *//*--------------------------------------------------------------------*/
2482306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyrystruct LineExitDiamond
2492306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry{
2502306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry	tcu::IVec2	position;
2512306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry};
2522306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry
2532306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry/*--------------------------------------------------------------------*//*!
2542306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry * \brief Line exit diamond generator
2552306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry *
2562306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry * For a given line, generates list of diamonds the line exits using the
2572306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry * line-exit rules of the line rasterization. Does not do scissoring.
2582306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry *
2592306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry * \note Not used by rr, but provided to prevent test cases requiring
2602306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry *       accurate diamonds from abusing SingleSampleLineRasterizer.
2612306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry *//*--------------------------------------------------------------------*/
2622306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyryclass LineExitDiamondGenerator
2632306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry{
2642306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyrypublic:
2652306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry									LineExitDiamondGenerator	(void);
2662306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry									~LineExitDiamondGenerator	(void);
2672306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry
2682306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry	void							init						(const tcu::Vec4& v0, const tcu::Vec4& v1);
2692306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry
2702306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry	// only available after init()
2712306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry	void							rasterize					(LineExitDiamond* const lineDiamonds, const int maxDiamonds, int& numWritten);
2722306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry
2732306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyryprivate:
2742306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry									LineExitDiamondGenerator	(const LineExitDiamondGenerator&); // not allowed
2752306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry	LineExitDiamondGenerator&		operator=					(const LineExitDiamondGenerator&); // not allowed
2762306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry
2772306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry	// Per-line rasterization state.
2782306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry	tcu::Vec4						m_v0;
2792306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry	tcu::Vec4						m_v1;
2802306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry	tcu::IVec2						m_bboxMin;			//!< Bounding box min (inclusive).
2812306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry	tcu::IVec2						m_bboxMax;			//!< Bounding box max (inclusive).
2822306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry	tcu::IVec2						m_curPos;			//!< Current rasterization position.
2832306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry};
2842306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // rr
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _RRRASTERIZER_HPP
288