Vigilante 3d Graphics
Triangle Processing

In computer graphics, the most common method of representing objects in three dimensional space is through the use of triangles and transforms.  Any shape can be approximated using triangles, and triangles are very easy to rasterize.  Many shapes, especially those with curves, can be represented using hundreds or even thousands of triangles.

Using SSE instruction, it is possible for the 3d rendering pipeline to process 4 triangles simultaneously.  However, this also poses a problem in cases where fewer than 4 triangles (which occur quite frequently, actually) are being processed.  In such cases, absent triangles are necessarily fudged so the pipeline can operate without error.

Triangles are fed to the geometry stage of the pipeline as sequential an array of structures.  This array of structures (called the stream) is "swizzled" for SSE processing as a structure of arrays.

struct Vertex
{
	Vector3 position;
	Vector3 normal;
	COLOR32 diffuse;
	Vector2 texture0;
	Vector2 texture1;
};

Vertex stream[4];
Swizzle >>
struct Vertex
{
	Vector3ps position[4];
	Vector3ps normal[4];
	COLOR32pi diffuse[4];
	Vector2ps texture0[4];
	Vector2ps texture1[4];
};

Vertex streamps;

Next Page: Pipeline Overview