What does the CPU do in rendering a modern game?

Associate
Joined
28 Jun 2005
Posts
2,174
Location
Behind you
Might be a stupid question but I will ask anyway:)

In a modern game, what does the CPU do that the GPU needs? Does the CPU render the scene with flat shaded polygons and nothing else, then the GPU adds textures, lighting, shaders ect, or does the CPU do more like texturing and lighting?

Ta
 
Not sure exactly, but it does things like the AI, sound management and various other things.
 
As far as I know it still calculates (not render) all the Basic 3D geometry (apart from stuff like tessellation, instancing etc, that's handled by the GPU)

Nate
 
I make console games for a living so hopefully can help :)
Typically, the CPU does no graphical, per-pixel 'rendering', per-se. The most graphical thing that is done is the construction of "display lists" aka "command lists" which are basically long, high-level sequences of instructions for the GPU to execute. They are not commands like "draw a red pixel at co-ordinate (123, 456)".

So in your game render loop, you iterate through each object that you'd like to draw and call its render function. That object then adds to the current display list a command to set the current position, rotation + scale of the model you'd like to draw. It then adds a command to set the visual state such as "I'd like these textures, this lighting and these shaders bound to the next model" and then adds the command to draw a model that's in memory.

Once this has all been done the command list is then sent to the GPU to execute.

There are non pixel-related rendering things though, such as calculating visibility of objects. For instance, there's no point in rendering objects behind the camera only to have the GPU automatically cull them out. This costs both CPU time (adding those invisible objects to the display list) and GPU time (since the GPU has to do run the vertex shaders, just to have the clipping phase classify them as behind the camera). So the CPU normally does a ray-trace like step to see if objects are visible. One such way of doing this for FPS games is to use BSP trees.

Rarely however you may want to do actual rendering on the CPU since the latency needed to do processing on the GPU and then get it back on the CPU is too high. We did this in a shipping game last year by using an old-skool software renderer to do it instead of the GPU.

Does this all make sense? ;)
 
As above the CPU will generally be sending "commands" to the GPU about what it wants rendered and the GPU will render it.

I am actually using the CPU to modify (in realtime) the contents of a texture buffer in my latest project because its currently not possible to do what I need with a shader - but thats a rareity these days.
 
...

Does this all make sense? ;)

Very insightful, I didn't like there tests of course in high GPU based games when you have no bottleneck on the CPU then the GPU is stopping progression ... and I will stop there since I am replying to the wrong thread :D

Still true tho..
 
Hmmmmmmmm, thanks guys:) If the CPU just sends commands to the GPU, then why does a slower CPU bottleneck a high-end GPU? Surely you don't need much CPU power to send commands to the GPU? Or, am I missing something?:)
 
Hmmmmmmmm, thanks guys:) If the CPU just sends commands to the GPU, then why does a slower CPU bottleneck a high-end GPU? Surely you don't need much CPU power to send commands to the GPU? Or, am I missing something?:)

Well the GPU can't do anything until the CPU tells it to. So if the CPU is taking a while to get to the point in the loop where it actually tells the GPU to start processing data through the shaders, then the GPU will just be sitting idle waiting to do something :)
 
Well the GPU can't do anything until the CPU tells it to. So if the CPU is taking a while to get to the point in the loop where it actually tells the GPU to start processing data through the shaders, then the GPU will just be sitting idle waiting to do something :)

Pretty much! Render set-up can often take a good chunk of a time. Plus don't forget it's got to do the actual game game in there too :D

Rroff, have you had a go with OpenCL or CUDA to see if you can do the things that you want? Or is just a no-go in this case? We've found that you can do a lot of odd things with compute shaders (like sorting or finding minimums) that you wouldn't necessary associate with a GPU.
 
Rroff, have you had a go with OpenCL or CUDA to see if you can do the things that you want? Or is just a no-go in this case? We've found that you can do a lot of odd things with compute shaders (like sorting or finding minimums) that you wouldn't necessary associate with a GPU.

not tried - performance wise runs fine especially on a moderm multi-thread capable CPU the main bottleneck if it comes to it is transfering to and from system memory.

CUDA wouldn't fly anyhow - after the shut out with PhysX its lost popularity around here and Open CL is still on the "wait and see".
 
Last edited:
This one time, someone told me that graphics cards were pointless because you could run any game if you had a fast enough CPU and loads of ram.

I lolled.
 
@OrphanBoy, is it true that a CPU has to do the same amount of work at 640*480 and 2560*1600 and it is only the GPU that has to do more work at a higher resolution?
 
Yeah I'd say so. I can't think of anything in a 'normal' game which should make the CPU work harder simply because the resolution increased. The same thing would apply to AA and AF. These should only increase the load on the GPU.

Two abnormal cases though where increasing the resolution would slow the CPU down:
- the image had to be post-processed by the CPU. In which case a bigger image would take longer to work on. (but that'd be an exceptional case)
- on a PC where the GPU had no dedicated memory or a really small store. Like integrated graphics, hyper memory cards or even that NV Optimus set-up. This would be because the GPU would be sapping the CPU<->RAM bandwidth as they'd both share the same bus. Larger frame buffers and better texture filtering and take lots of bandwidth.
 
I heard that on the PS3 the Cell's "special cores" can be and are used to do things the GPU can't, like shaders and other special effects. Is it true?
 
Back
Top Bottom