Could you explain a bit how the main thread and render thread interact with regards to their timing? The frame graph has shown a lot of wierd things like a ‘pulse’ of increased MT time every few seconds in some locations. Most locations also have spots where moving the camera left and right repeatedly can increase both the MT and RT time and cause some kind of frame stuttering as a result. STARC-156858 Here is a location that can cause up to 75ms increase by shaking the camera while looking at it for a few seconds. I have screenshots showing the frame graph.
BTW, screenshots ‘spoil’ the output of the frame graph by causing their own spike in frame generation time which is recorded on the resultant screenshot.
Could you explain a bit how the main thread and render thread interact with regards to their timing?
To fully answer this I’d need to extensively profile the latest version of the game and write you a 10,000 word report! There dozen of teams with dozens of systems each, and each of those have their own quirks with how they are optimised and depend on one another.
But for the most part the MT and RT and GPU are all completely separate and run in parallel, mostly with only a single point of synchronisation per frame. However whichever is the slowest can/will cause a chain reaction of impacts to the others. Without profiling your specific case I can’t say what will cause the spikes you refer to, but here are some example scenarios:
– A slow GPU frame (e.g. more characters visible) means the RT can’t start submitting new work to the GPU, which then blocks the MT from simulating the next game/physics step
– The culling system uses the rendering information from 2 frames ago to predict what will be occluded, but when turning you are seeing new areas that weren’t visible 2 frames ago so any objects in those areas can’t be culled as accurately. So shaking the camera can result in more objects being renderer, which adds cost to both the RT and GPU.
– Some objects only update every N frames, because it’s very hard to have a single object only update say 10%, generally objects either update or they don’t. To avoid spikes each object’s update is offset by a few frames such that they don’t all end up updating at the same time. But if theres one particularly expensive object or if there is a bug/bad-setup then you can end up seeing regular spikes.