Of the GPU and Shading

This is my favorite part, really. After the CPU has started sending draw calls to the graphics card, the GPU can begin work on actually rendering the frame containing the input that was generated somewhere in the vicinity of 3ms to 21ms ago depending on the software (and it would be an additional 1ms to 7ms for a slower mouse). Modern, complex, games will tend push up to the long end of that spectrum, while older games (or games that aren't designed to do a lot of realistic simulation like twitch shooters) will have a lower latency.

Again, the actual latency during this stage depends greatly on the complexity of the scene and the techniques used in the game.

These days, geometry processing and vertex shading tend to be pretty fast (geometry shading is slower but less frequently used). With features like instancing and the fact that the majority of detail is introduced via the pixel shader (which is really a fragment shader, but we'll dispense with the nit picking for now). If the use of tessellation catches on after the introduction of DX11, we could see even less actual time spent on geometry as the current level of detail could be achieved with fewer triangles (or we could improve quality with the same load). This step could still take a millisecond or two with modern techniques.

When it comes to actual fragment generation from the geometry data (called rasterization), the fixed function hardware and early z / z culling techniques used make this step pretty fast (yet this can be the limiting factor in how much geometry a GPU can realistically handle per frame).

Most of our time will likely be spent processing pixel shader programs. This is the step where every pin point spot on every triangle that falls behind the area of a screen space pixel (these pin point spots are called fragments) is processed and its color determined. During this step, texture maps are filtered and applied, work is done on those textures based on things like the fragments location, the angle of the underlying triangle to the screen, and constants set for the fragment. Lighting is also part of the pixel shading process.

Lighting tends to be one of the heaviest loads in a heavily loaded portion of the pipeline. Realistic lighting can be very GPU intensive. Getting into the specifics is beyond the scope of this article, but this lighting alone can take a good handful of milliseconds for an entire frame. The rest of the pixel shading process will likely also take multiple milliseconds.

After it's all said and done, with the pixel shader as the bottleneck in modern games, we're looking at something like 6ms to 25ms. In fact, the latency of the pixel shaders can hide a lot of the processing time of other parts of the GPU. For instance, pixel shaders can start executing before all the geometry is processed (pixel shaders are kicked off as fragments start coming out of the rasterizer). The color/z hardware (render outputs, render backends or ROPs depending on what you want to call them) can start processing final pixels in the framebuffer while the pixel shader hardware is still working on the majority of the scene. The only real latency that is added by the geometry/vertex processing portion of the pipeline is the latency that happens before the first pixels begin processing (which isn't huge). The only real latency added by the ROPs is the processing time for the last batch of pixels coming out of the pixel shaders (which is usually not huge unless really complicated blending and stencil technique are used).

With the pixel shader as the bottleneck, we can expect that the entire GPU pipeline will add somewhere between 10ms and 30ms. This is if we consider that most modern games, at the resolutions people run them, produce something between 33 FPS and 100 FPS.

But wait, you might say, how can our framerate be 33 to 100 FPS if our graphics card latency is between 10ms and 30ms: don't the input and CPU time latencies add to the GPU time to lower framerate?

The answer is no. When we are talking about the total input lag, then yes we do have to add these latencies together to find out how long it has been since our input was gathered. After the GPU, we are up to something between 13ms and 58ms of input lag. But the cool thing is that human response happens in parallel to input gathering which happens in parallel to CPU time spent processing game logic and draw calls (which can happen in parallel to each other on multicore CPUs) which happens in parallel to the GPU rendering frames. There is a sequential path from input to the screen, but we can almost look at this like a heavily pipelined path where each stage operates in parallel on a different upcoming frame.

So we have the GPU rendering the previous frame while simulation and game logic are executing and input is being gathered for the next frame. In this way, the CPU can be ready to send more draw calls to the GPU as soon as the GPU is ready (provided only that we are not CPU limited).

So what happens after the frame is finished? The easy answer is a buffer swap and scanout. The subtle answer is mounds of potential input lag.

Parsing Input in Software and the CPU Limit Scanout and the Display
Comments Locked

85 Comments

View All Comments

  • RubberJohnny - Friday, July 17, 2009 - link

    OT - I used to be a diehard CRT ONLY user then i realised there is NO ghosting on modern LCD monitors...you may have seen smearing on LCD tvs but thats caused but the scaler resizing SD material to fit the panels native res.
    On monitors there is no scaling = no ghosting.
    Got a 24inch samsung 6 months ago and wish i'd done so earlier, crisper, larger image and widescreen being the main reasons i'll NEVER use a crt again.
  • DerekWilson - Friday, July 17, 2009 - link

    I agree that with modern LCD panels ghosting is not as large an issue and color (depending on backlight) and contrast (depending on panel) are much better these days as well.

    Refresh rate is the only real outstanding issue these days (imo). And the only 120Hz display I saw was a bit over saturated / over bright and not high enough contrast.
  • jkostans - Saturday, July 18, 2009 - link

    I have yet to see an LCD without ghosting, it may be minor but it's still annoying. And even the 120Hz LCDs supposedly still have measurable input lag regardless of the non-existent ghosting. LCDs are still a downgrade as far as I'm concerned.
  • DerekWilson - Sunday, July 19, 2009 - link

    Well you can actually see how much (or little) ghosting there would be in our high speed footage... even the advertised latencies on the 3007WFP are pretty bad compared to most panels these days (especially TN panels). Despite that there were only a few cases where we could see ghosting take a whole frame (and it never seemed to take more than a whole frame).

    We should test more panels with high speed cameras and see what happens...
  • Freeseus - Thursday, July 16, 2009 - link

    I feel like there is a HUGE section of delay missing from this article. Perhaps it was chosen specifically not to be included because rigorous testing/comparison would have to be performed in order to show any sort of suggested "average" numbers. Either way, I feel it should have been addressed... even if it were just at the end of the article.

    I'm referring to the added delay of wireless mice.

    Aside from the added delay of transmitting all the mouse action to the receiver, the biggest issue is the inconsistencies of mouse performance and precision. I'm sure there's a direct correlation between this and the battery. I'm referring specifically to the amount of battery used up in order for the mouse to broadcast continuously at extremely high intervals to insure precise movement. But obviously this includes any issue where the battery needs to be recharged as well. And on top of that, the mouse seems to be non-responsive occasionally during use. Completely unacceptable in a work or 'twitch gaming' environment.

    Anyhow, it would have been nice to see this addressed because many people make the argument that wireless mice are better. And when it comes to FPS gaming or even work, I can't think of a reason not to have a wired mouse. Do I really need to have that accuracy all the time. Yes.
  • DerekWilson - Thursday, July 16, 2009 - link

    I agree that the current state of wireless mice is generally pretty poor ... though I've never used a wireless mouse targeted at gaming (gaming mice were the first optical mice I was able to use without mousing too quickly for the sensor even during desktop use).

    Testing wireless mice is definitely something worth looking into.
  • Vidmar - Friday, July 17, 2009 - link

    What about PS/2 mice? Are they better or worse than USB?
  • DerekWilson - Friday, July 17, 2009 - link

    PS/2 mice are slower ... iirc they come in at about 100Hz (10ms).
  • Vidmar - Monday, July 20, 2009 - link

    Really?? My old PS/2 MS Wheel Optical Mouse v1.1 is currently running at 200Mhz. IE: 200 reports/second. I've never felt like it doesn't keep up in any game.
  • lopri - Thursday, July 16, 2009 - link

    I'm loving this article and chewing threw every page right now. Just wanted to say thank you for such in-depth analysis as is rarely found elsewhere.

Log in

Don't have an account? Sign up now