Vertex cache optimization

Feedback on past, current, and future development.
Post Reply
User avatar
halbe
Posts: 65
Joined: 14 Feb 2017, 03:55

Vertex cache optimization

Post 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
User avatar
psi29a
Posts: 5356
Joined: 29 Sep 2011, 10:13
Location: Belgium
Gitlab profile: https://gitlab.com/psi29a/
Contact:

Re: Vertex cache optimization

Post by psi29a »

Neat and this can be done programmatically at run-time?
User avatar
scrawl
Posts: 2152
Joined: 18 Feb 2012, 11:51

Re: Vertex cache optimization

Post 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.
User avatar
akortunov
Posts: 899
Joined: 13 Mar 2017, 13:49
Location: Samara, Russian Federation

Re: Vertex cache optimization

Post 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.
User avatar
scrawl
Posts: 2152
Joined: 18 Feb 2012, 11:51

Re: Vertex cache optimization

Post 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.
User avatar
akortunov
Posts: 899
Joined: 13 Mar 2017, 13:49
Location: Samara, Russian Federation

Re: Vertex cache optimization

Post 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.
User avatar
AnyOldName3
Posts: 2667
Joined: 26 Nov 2015, 03:25

Re: Vertex cache optimization

Post 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.
Post Reply