Game Engine Architecture

(Ben Green) #1

408 10. The Rendering Engine


In a strip, the fi rst three vertices defi ne the fi rst triangle. Each subsequent
vertex forms an entirely new triangle, along with its previous two neigh-
bors. To keep the winding order of a triangle strip consistent, the previous
two neighbor vertices swap places aft er each new triangle. A triangle strip is
shown in Figure 10.8.
In a fan, the fi rst three vertices defi ne the fi rst triangle and each subse-
quent vertex defi nes a new triangle with the previous vertex and the fi rst ver-
tex in the fan. This is illustrated in Figure 10.9.

Vertex Cache Optimization
When a GPU processes an indexed triangle list, each triangle can refer to any
vertex within the vertex buff er. The vertices must be processed in the order
they appear within the triangles, because the integrity of each triangle must be
maintained for the rasterization stage. As vertices are processed by the vertex
shader , they are cached for reuse. If a subsequent primitive refers to a vertex
that already resides in the cache, its processed att ributes are used instead of
reprocessing the vertex.
Strips and fans are used in part because they can potentially save memory
(no index buff er required) and in part because they tend to improve the cache
coherency of the memory accesses made by the GPU to video RAM. Even
bett er, we can use an indexed strip or indexed fan to virtually eliminate vertex
duplication (which can oft en save more memory than eliminating the index
buff er), while still reaping the cache coherency benefi ts of the strip or fan ver-
tex ordering.
Indexed triangle lists can also be cache-optimized without restricting
ourselves to strip or fan vertex ordering. A vertex cache optimizer is an offl ine
geometry processing tool that att empts to list the triangles in an order that

Figure 10.9. A triangle fan.

Interpreted
as triangles:^012023034

Vertices V 0 V 1 V 2 V 3 V 4

V 0

V 4

V 3 V 2

V 1
Free download pdf