13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef _RRPRIMITIVEASSEMBLER_HPP
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define _RRPRIMITIVEASSEMBLER_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 Primitive assembler
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "rrDefs.hpp"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "rrVertexPacket.hpp"
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace rr
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace pa
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Triangle
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enum
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		NUM_VERTICES = 3
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Triangle (void)
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: v0				(DE_NULL)
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, v1				(DE_NULL)
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, v2				(DE_NULL)
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, provokingIndex	(-1)
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Triangle (VertexPacket* v0_, VertexPacket* v1_, VertexPacket* v2_, int provokingIndex_)
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: v0				(v0_)
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, v1				(v1_)
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, v2				(v2_)
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, provokingIndex	(provokingIndex_)
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexPacket* getProvokingVertex (void)
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		switch (provokingIndex)
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			case 0: return v0;
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			case 1: return v1;
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			case 2: return v2;
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			default:
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				DE_ASSERT(false);
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				return DE_NULL;
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexPacket*	v0;
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexPacket*	v1;
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexPacket*	v2;
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				provokingIndex;
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Triangles
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	template <typename Iterator>
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static void exec (Iterator outputIterator, VertexPacket* const* vertices, size_t numVertices, rr::ProvokingVertex provokingConvention)
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int provokingOffset = (provokingConvention == rr::PROVOKINGVERTEX_FIRST) ? (0) : (2);
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (size_t ndx = 0; ndx + 2 < numVertices; ndx += 3)
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			*(outputIterator++) = Triangle(vertices[ndx], vertices[ndx+1], vertices[ndx+2], provokingOffset);
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static size_t getPrimitiveCount (size_t vertices)
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return vertices / 3;
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct TriangleStrip
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	template <typename Iterator>
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static void exec (Iterator outputIterator, VertexPacket* const* vertices, size_t numVertices, rr::ProvokingVertex provokingConvention)
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (numVertices < 3)
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		else
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			VertexPacket* vert0 = vertices[0];
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			VertexPacket* vert1 = vertices[1];
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			size_t ndx = 2;
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (;;)
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					if (ndx >= numVertices)
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						break;
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					*(outputIterator++) = Triangle(vert0, vert1, vertices[ndx], (provokingConvention == rr::PROVOKINGVERTEX_FIRST) ? (0) : (2));
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					vert0 = vertices[ndx];
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					ndx++;
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					if (ndx >= numVertices)
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						break;
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					*(outputIterator++) = Triangle(vert0, vert1, vertices[ndx], (provokingConvention == rr::PROVOKINGVERTEX_FIRST) ? (1) : (2));
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					vert1 = vertices[ndx];
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					ndx++;
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static size_t getPrimitiveCount (size_t vertices)
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return (vertices < 3) ? (0) : (vertices - 2);
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct TriangleFan
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	template <typename Iterator>
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static void exec (Iterator outputIterator, VertexPacket* const* vertices, size_t numVertices, rr::ProvokingVertex provokingConvention)
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (numVertices == 0)
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		else
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int			provokingOffset	= (provokingConvention == rr::PROVOKINGVERTEX_FIRST) ? (1) : (2);
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			VertexPacket* const	first			= vertices[0];
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (size_t ndx = 1; ndx + 1 < numVertices; ++ndx)
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				*(outputIterator++) = Triangle(first, vertices[ndx], vertices[ndx+1], provokingOffset);
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static size_t getPrimitiveCount (size_t vertices)
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return (vertices < 3) ? (0) : (vertices - 2);
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Line
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enum
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		NUM_VERTICES = 2
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Line (void)
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: v0				(DE_NULL)
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, v1				(DE_NULL)
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, provokingIndex	(-1)
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Line (VertexPacket* v0_, VertexPacket* v1_, int provokingIndex_)
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: v0				(v0_)
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, v1				(v1_)
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, provokingIndex	(provokingIndex_)
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexPacket* getProvokingVertex (void)
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		switch (provokingIndex)
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			case 0: return v0;
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			case 1: return v1;
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			default:
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				DE_ASSERT(false);
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				return DE_NULL;
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexPacket*	v0;
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexPacket*	v1;
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				provokingIndex;
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Lines
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	template <typename Iterator>
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static void exec (Iterator outputIterator, VertexPacket* const* vertices, size_t numVertices, rr::ProvokingVertex provokingConvention)
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int provokingOffset = (provokingConvention == rr::PROVOKINGVERTEX_FIRST) ? (0) : (1);
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (size_t ndx = 0; ndx + 1 < numVertices; ndx += 2)
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			*(outputIterator++) = Line(vertices[ndx], vertices[ndx+1], provokingOffset);
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static size_t getPrimitiveCount (size_t vertices)
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return vertices / 2;
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct LineStrip
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	template <typename Iterator>
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static void exec (Iterator outputIterator, VertexPacket* const* vertices, size_t numVertices, rr::ProvokingVertex provokingConvention)
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (numVertices == 0)
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		else
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			VertexPacket* prev = vertices[0];
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (size_t ndx = 1; ndx < numVertices; ++ndx)
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				*(outputIterator++) = Line(prev, vertices[ndx], (provokingConvention == rr::PROVOKINGVERTEX_FIRST) ? (0) : (1));
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				prev = vertices[ndx];
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static size_t getPrimitiveCount (size_t vertices)
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return (vertices < 2) ? (0) : (vertices - 1);
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct LineLoop
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	template <typename Iterator>
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static void exec (Iterator outputIterator, VertexPacket* const* vertices, size_t numVertices, rr::ProvokingVertex provokingConvention)
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (numVertices < 2)
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		else
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			VertexPacket* prev = vertices[0];
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (size_t ndx = 1; ndx < numVertices; ++ndx)
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				*(outputIterator++) = Line(prev, vertices[ndx], (provokingConvention == rr::PROVOKINGVERTEX_FIRST) ? (0) : (1));
2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				prev = vertices[ndx];
2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			*(outputIterator++) = Line(prev, vertices[0], (provokingConvention == rr::PROVOKINGVERTEX_FIRST) ? (0) : (1));
2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static size_t getPrimitiveCount (size_t vertices)
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return (vertices < 2) ? (0) : (vertices);
2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Point
2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enum
2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		NUM_VERTICES = 1
2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Point (void)
2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: v0(DE_NULL)
2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Point (VertexPacket* v0_)
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: v0(v0_)
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexPacket* v0;
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Points
2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	template <typename Iterator>
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static void exec (Iterator outputIterator, VertexPacket* const* vertices, size_t numVertices, rr::ProvokingVertex provokingConvention)
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_UNREF(provokingConvention);
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (size_t ndx = 0; ndx < numVertices; ++ndx)
3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			*(outputIterator++) = Point(vertices[ndx]);
3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static size_t getPrimitiveCount (size_t vertices)
3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return (vertices);
3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct LineAdjacency
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enum
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		NUM_VERTICES = 4
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LineAdjacency (void)
3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: v0				(DE_NULL)
3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, v1				(DE_NULL)
3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, v2				(DE_NULL)
3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, v3				(DE_NULL)
3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, provokingIndex	(-1)
3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	LineAdjacency (VertexPacket* v0_, VertexPacket* v1_, VertexPacket* v2_, VertexPacket* v3_, int provokingIndex_)
3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: v0				(v0_)
3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, v1				(v1_)
3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, v2				(v2_)
3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, v3				(v3_)
3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, provokingIndex	(provokingIndex_)
3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexPacket* getProvokingVertex (void)
3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		switch (provokingIndex)
3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			case 1: return v1;
3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			case 2: return v2;
3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			default:
3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				DE_ASSERT(false);
3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				return DE_NULL;
3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexPacket*	v0;
3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexPacket*	v1;
3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexPacket*	v2;
3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexPacket*	v3;
3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				provokingIndex;
3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct LinesAdjacency
3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	template <typename Iterator>
3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static void exec (Iterator outputIterator, VertexPacket* const* vertices, size_t numVertices, rr::ProvokingVertex provokingConvention)
3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int provokingOffset = (provokingConvention == rr::PROVOKINGVERTEX_FIRST) ? (1) : (2);
3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (size_t ndx = 0; ndx + 3 < numVertices; ndx += 4)
3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			*(outputIterator++) = LineAdjacency(vertices[ndx], vertices[ndx+1], vertices[ndx+2], vertices[ndx+3], provokingOffset);
3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static size_t getPrimitiveCount (size_t vertices)
3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return vertices / 4;
3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct LineStripAdjacency
3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	template <typename Iterator>
3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static void exec (Iterator outputIterator, VertexPacket* const* vertices, size_t numVertices, rr::ProvokingVertex provokingConvention)
3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int provokingOffset = (provokingConvention == rr::PROVOKINGVERTEX_FIRST) ? (1) : (2);
3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (size_t ndx = 0; ndx + 3 < numVertices; ++ndx)
3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			*(outputIterator++) = LineAdjacency(vertices[ndx], vertices[ndx+1], vertices[ndx+2], vertices[ndx+3], provokingOffset);
3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static size_t getPrimitiveCount (size_t vertices)
3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return (vertices < 4) ? (0) : (vertices - 3);
3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct TriangleAdjacency
3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enum
3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		NUM_VERTICES = 6
3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TriangleAdjacency (void)
3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: v0				(DE_NULL)
3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, v1				(DE_NULL)
3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, v2				(DE_NULL)
4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, v3				(DE_NULL)
4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, v4				(DE_NULL)
4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, v5				(DE_NULL)
4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, provokingIndex	(-1)
4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TriangleAdjacency (VertexPacket* v0_, VertexPacket* v1_, VertexPacket* v2_, VertexPacket* v3_, VertexPacket* v4_, VertexPacket* v5_, int provokingIndex_)
4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: v0				(v0_)
4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, v1				(v1_)
4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, v2				(v2_)
4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, v3				(v3_)
4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, v4				(v4_)
4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, v5				(v5_)
4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, provokingIndex	(provokingIndex_)
4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexPacket* getProvokingVertex (void)
4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		switch (provokingIndex)
4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			case 0: return v0;
4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			case 2: return v2;
4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			case 4: return v4;
4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			default:
4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				DE_ASSERT(false);
4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				return DE_NULL;
4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexPacket*	v0;
4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexPacket*	v1;	//!< adjacent
4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexPacket*	v2;
4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexPacket*	v3;	//!< adjacent
4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexPacket*	v4;
4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexPacket*	v5;	//!< adjacent
4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				provokingIndex;
4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct TrianglesAdjacency
4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	template <typename Iterator>
4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static void exec (Iterator outputIterator, VertexPacket* const* vertices, size_t numVertices, rr::ProvokingVertex provokingConvention)
4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const int provokingOffset = (provokingConvention == rr::PROVOKINGVERTEX_FIRST) ? (0) : (4);
4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (size_t ndx = 0; ndx + 5 < numVertices; ndx += 6)
4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			*(outputIterator++) = TriangleAdjacency(vertices[ndx], vertices[ndx+1], vertices[ndx+2], vertices[ndx+3], vertices[ndx+4], vertices[ndx+5], provokingOffset);
4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static size_t getPrimitiveCount (size_t vertices)
4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return vertices / 6;
4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct TriangleStripAdjacency
4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	template <typename Iterator>
4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static void exec (Iterator outputIterator, VertexPacket* const* vertices, size_t numVertices, rr::ProvokingVertex provokingConvention)
4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (numVertices < 6)
4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		else if (numVertices < 8)
4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			*(outputIterator++) = TriangleAdjacency(vertices[0], vertices[1], vertices[2], vertices[5], vertices[4], vertices[3], (provokingConvention == rr::PROVOKINGVERTEX_FIRST) ? (0) : (4));
4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		else
4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const size_t primitiveCount = getPrimitiveCount(numVertices);
4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			size_t i;
4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// first
4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			*(outputIterator++) = TriangleAdjacency(vertices[0], vertices[1], vertices[2], vertices[6], vertices[4], vertices[3], (provokingConvention == rr::PROVOKINGVERTEX_FIRST) ? (0) : (4));
4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// middle
4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (i = 1; i + 1 < primitiveCount; ++i)
4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				// odd
4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if (i % 2 == 1)
4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					*(outputIterator++) = TriangleAdjacency(vertices[2*i+2], vertices[2*i-2], vertices[2*i+0], vertices[2*i+3], vertices[2*i+4], vertices[2*i+6], (provokingConvention == rr::PROVOKINGVERTEX_FIRST) ? (2) : (4));
4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				// even
4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				else
4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				{
4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					*(outputIterator++) = TriangleAdjacency(vertices[2*i+0], vertices[2*i-2], vertices[2*i+2], vertices[2*i+6], vertices[2*i+4], vertices[2*i+3], (provokingConvention == rr::PROVOKINGVERTEX_FIRST) ? (0) : (4));
4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				}
4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// last
4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// odd
4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (i % 2 == 1)
4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				*(outputIterator++) = TriangleAdjacency(vertices[2*i+2], vertices[2*i-2], vertices[2*i+0], vertices[2*i+3], vertices[2*i+4], vertices[2*i+5], (provokingConvention == rr::PROVOKINGVERTEX_FIRST) ? (2) : (4));
4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			// even
4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			else
5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				*(outputIterator++) = TriangleAdjacency(vertices[2*i+0], vertices[2*i-2], vertices[2*i+2], vertices[2*i+5], vertices[2*i+4], vertices[2*i+3], (provokingConvention == rr::PROVOKINGVERTEX_FIRST) ? (0) : (4));
5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static size_t getPrimitiveCount (size_t vertices)
5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return (vertices < 6) ? 0 : ((vertices - 4) / 2);
5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // pa
5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // rr
5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _RRPRIMITIVEASSEMBLER_HPP
514