My main triple A task today has been finding and solving the performance spike we see when in high combat. After some VTuning, it was apparent that 25% of the main thread cycles was dedicated to doing a triangle intersection test, which in turn comes from the functionality which casts a ray between the enemy and the player to determine if the player can be seen or hit with a bullet. In play, my framer rate can go from 90 fps down to 25 fps when five characters are running around shooting me, so not ideal.
The good news is that I added some code (and ate 8MB of valuable system memory) to add what I called a 'skipgrid' which remembers the position of the enemy and the destination of the ray and stores what the hit value was. The next time the intersection command is called, I can do a quick look-up to see if this ray was done before, and instantly return the result. I also added code to limit the engine to a maximum of five intersect tests per cycle so this part of the engine does not swallow up other resources. I am sure there will be some after effects of this optimization, but the new frame rates are much improved. In a high combat scenario with five aggressors, there is little to no frame rate drop during the fighting. You do see a drop when you shoot the shotgun, but that's because it has five ray casts being sent out all at once. Most weapons would not exhibit this 'blip' but I will see what testing feedback results first to see if anyone notices this amongst all the other things going on.
I am writing my blog early today as I have a meeting with the accountants tomorrow, part of my 'Managing Director' hat. I need time to assemble some paperwork and get my head out of code and into facts and figures. They may appear to be in the same mental ballpark, but games coding is much more fun!
Not right now though, it's still full steam ahead and after a nice cup of tea I will be looking closer at the occluder system. If you recall, this is the CPU based system of detecting which objects are being completely hidden by closer objects and removing them from the render scene. You may also recall that switching it on actually caused the frame rate to drop, not increase, so I will be making an assault on that code and finding out the whys and wherefores.
In other news I have my artist back from the land of the ConKit, which means I can start some work on the pistol grip animations, LOD levels for even faster scene renders and other nice graphic tweaks :)
Good news by the sounds! The AI when in groups is really a frame killer at the moment. Having things slow to a crawl with just 5 people around shooting was not a good sign for anyone wanting Zombie hordes or indeed any kind of horde.
ReplyDeleteI hope you find the issue with the occlusion, as I think that will be a major factor in improving big levels. Having almost 1,000,000 polys on screen when at one corner of the map and looking in, is a lot of polygons!
I really think you should be using Bullet's raycasts, not your own. I'm assuming that's the reason for the speed drop, because I've never heard of 5 raycasts causing such a slowdown before. Bullet should be a gazillion times faster. Ah, of course you can't do Bullet raycasts on skinned characters now can you... hmm....
ReplyDelete