I set up a basic test of Occlusion Queries on the current framework, just to satisfy myself that the ideas I had here were viable. Result is that I can pull maybe an extra 20 FPS out of that really bad scene, and get minor gains everywhere else, so it's definitely something worth pursuing further.
I was able to completely bypass the normal pipeline stalls associated with Occlusion Queries by assuming that on a really small timescale things don't actually change that much from frame to frame, and that over 90% of the time the results for any one given frame are going to be valid for the next frame. My tests have confirmed this assumption to be valid, so it's the way forward. The sequence is therefore: read back the results for the previous frame; if they're not ready yet just use the last valid result, then issue a new set of queries (this last can be deferred until such a time as the previous results become ready, with a timeout of something like 2 or 3 frames where if they're not ready by then we discard them).
It should also be possible to further optimize by just not running queries against certain entities. An entity in the same leaf as the player is one candidate, another would be any entity who's model is sufficiently simple that it's not worth bothering. The overhead from the query far outweighs the cost of just drawing it regardless.
I'll be doing the first release without it though. Reason why is because of the way Quake handles reuse of entities; I need to be extra careful here as by the time the results come in the entity that the original query was run against may have completely changed! Any fool can get maximum performance if they're not worried about correctness (at the most extreme end of the scale it can be done by drawing absolutely nothing), and getting correctness without worrying about performance isn't that difficult either. Getting both together involves more work, and I'm not ready to include this feature without nailing it down better.
Sunday, January 10, 2010
More on Occlusion Queries
Posted by
mhquake
at
2:09 PM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment