Vertex cache optimization

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

Vertex cache optimization

Post by halbe » 23 Dec 2017, 19:17

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: 3481
Joined: 29 Sep 2011, 10:13
Github profile: https://github.com/psi29a/
Contact:

Re: Vertex cache optimization

Post by psi29a » 23 Dec 2017, 21:19

Neat and this can be done programmatically at run-time?

User avatar
scrawl
Posts: 2103
Joined: 18 Feb 2012, 11:51
Contact:

Re: Vertex cache optimization

Post by scrawl » 24 Dec 2017, 23:26

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: 170
Joined: 13 Mar 2017, 13:49
Location: Samara, Russian Federation
Github profile: https://github.com/akortunov

Re: Vertex cache optimization

Post by akortunov » 25 Dec 2017, 15:03

[/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: 2103
Joined: 18 Feb 2012, 11:51
Contact:

Re: Vertex cache optimization

Post by scrawl » 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.

User avatar
akortunov
Posts: 170
Joined: 13 Mar 2017, 13:49
Location: Samara, Russian Federation
Github profile: https://github.com/akortunov

Re: Vertex cache optimization

Post by akortunov » 25 Dec 2017, 17:53

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: 621
Joined: 26 Nov 2015, 03:25

Re: Vertex cache optimization

Post by AnyOldName3 » 26 Dec 2017, 02:22

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.
AnyOldName3, Master of Shadows

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests