Page 1 of 1

Vertex cache optimization

Posted: 23 Dec 2017, 19:17
by halbe
I am the emissary of the great and mighty Greatness7 who has discovered that reordering the faces in a .nif file leads to significant performance increases in both vanilla and openmw (or any game, this is apparently a well-known concept), and this is a feature that could be added to the mesh loader. In his test I got 440FPS with regular .nifs and 720FPS with optimized ones (in a cell full of Suzannas).

Apparently the GPU keeps a cache of recently seen vertices and it loads from the cache faster than it does from VRAM, and this makes it so it is able to load from the cache more often. Imagine a mesh of a pizza with one vertex at the center that connects all the slices, if the faces are ordered in a way that all the slices that use the same center vertex are adjacent to each other then it can just keep the center vertex in the cache instead of loading the vertices for the crust. Then when it loads the crust it will load crust from slices that are next to each other since they share vertices.

More specifics can be found here:
https://tomforsyth1000.github.io/papers ... e_opt.html
http://gameangst.com/?p=9

Here's the test file with instructions: https://a.safe.moe/hwS9Y.7z

Re: Vertex cache optimization

Posted: 23 Dec 2017, 21:19
by psi29a
Neat and this can be done programmatically at run-time?

Re: Vertex cache optimization

Posted: 24 Dec 2017, 23:26
by scrawl
Yes, and OSG has a ready-made class:

https://github.com/openscenegraph/OpenS ... mizers#L59

If we can prove this has a benefit and the loading time is negligible, we might want to use it.

Re: Vertex cache optimization

Posted: 25 Dec 2017, 15:03
by akortunov
[/quote]
scrawl wrote: 24 Dec 2017, 23:26 Yes, and OSG has a ready-made class
According to our optimizer code, OpenMW already supports it, but does not use by default.
halbe wrote: 23 Dec 2017, 19:17 In his test I got 440FPS with regular .nifs and 720FPS with optimized ones (in a cell full of Suzannas).
The FPS boost can be different in the real gameplay.
For example, on my PC I do not get any FPS boost from mesh optimizer at all (despite I use a lot of mesh/texture replacers).
Also I see no difference when the vertex cache optimization is enabled.

But it worth to test on different hardware anyway.

Re: Vertex cache optimization

Posted: 25 Dec 2017, 16:58
by scrawl
Well, for starters, you'd need a setup that is GPU limited to begin with (the orange bar) or there could hardly be an improvement. Might need a 4k screen or something.

Re: Vertex cache optimization

Posted: 25 Dec 2017, 17:53
by akortunov
scrawl wrote: 25 Dec 2017, 16:58 Well, for starters, you'd need a setup that is GPU limited to begin with (the orange bar).
I already have the one. OpenMW with high settings fully utilizes my GTX 1050.

Re: Vertex cache optimization

Posted: 26 Dec 2017, 02:22
by AnyOldName3
scrawl wrote: 25 Dec 2017, 16:58 Well, for starters, you'd need a setup that is GPU limited to begin with (the orange bar) or there could hardly be an improvement. Might need a 4k screen or something.
Surely it'd be the vertex stage, not the fragment stage that was helped by this optimisation, so it should only help if lots of mesh replacers are used, as output resolution shouldn't be affecting the vertex stage unless tessellation is used.