8
$\begingroup$

I've been digging a bit into what actually happens at a hardware level on the GPU, and found NVidia's Life of a triangle which explains the pipeline pretty well, at least for green boxes. One thing I wasn't clear on is what happens with indexed meshes, when the same vertex is used for a bunch of different triangles. Since data is generally not persisted for any longer than necessary in a stream processor, I'm guessing the vertex is simply destroyed after being rasterized, then fetched and run through the vertex shader again whenever it appears in a new triangle. Can anyone confirm this? Also, what happens in line-strip or triangle-strip modes? Does the GPU persist the transformed vertex data somewhere until the 2 or 3 relevant primitives have been rasterized in these cases?

$\endgroup$
5
$\begingroup$

The key expression you may be looking for is "Post Transform Cache".

This is usually effective because of the natural vertex reuse, but reordering your mesh, e.g. with Hoppe's method (note: the page also lists some more recent work) or Forsyth's can improve things further.

$\endgroup$
  • 1
    $\begingroup$ Yup, that's the one. Thanks. :-) I've been doing indexed Marching Cubes on pretty large volumes and was curious about how they were being rendered, as vertex locality is pretty bad between slices. Makes sense to cache the vertices somewhere (I guess just in standard L1 / 2 cache?). My meshes are probably out-of order enough to be re-processing a lot of vertices, so I'll look into those algorithms. $\endgroup$ – russ Aug 16 '16 at 9:06
4
$\begingroup$

That depends on how far apart the vertexes are reused.

For example the square 0, 1, 2, 2, 1, 3 will have a short enough interval that the 1 and 2 vertices will be reused. But if there are a hundred vertices between reuses then it's more likely that there will be no reuse.

But when they are much further apart then the vertex will fall out of the cache and have to be reprocessed by the vertex shader.

This is why some 3D software have a way to improve vertex locality for indexed meshes by reordering the vertices.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.