3
\$\begingroup\$

I'm interested in game development and 3D graphics; however, I'm not very experienced, so I apologize in advance if this comes across as ignorant or overly general.

The impression I get is that quite often the bottleneck in 3D games comes from the CPU having to make draw calls to the GPU. Culling seems to generally be performed on the CPU and then, for each frame, the CPU has to transfer the culled scene graph over to the GPU memory for rendering and display.

However, why can't culling be done on the GPU? It seems to be a very repetitive and predictable task that has to be done for every frame and would benefit from parallelization. Why not store the whole active scene graph in the GPU RAM; let the CPU just update what needs to be updated each frame (due to physics, animation, scripting, whatever); then fire a single 'draw' call to the GPU and have it cull and render everything? It seems to me it should be more efficient, because it would hugely reduce the amount of data transfer going on between CPU/GPU.

\$\endgroup\$
4
\$\begingroup\$

Non-optimality in terms of architecture. Wrong tool for the job.

GPU-optimal tasks are highly parallel: vertex processing, texture processing, computing boid motion, with all kernel-threads running in parallel from start to finish.

Culling, OTOH, is all about questions / conditionals e.g. "is this object in this view at this time given these conditions?". There are severe performance impacts when one GPU thread fails while all the others pass, because GPUs expect all pipelines to execute a kernel in parallel from start to finish.

So culling has tended to be better suited to calculation on the CPU, which is built for branching without stalling the entire pipeline (c.f. branch prediction, which GPUs lack) on a failed branch.

Think of it like this: GPU's processing profile is "many small things at once without branches"; CPU's domain is "give me any problem large or small, conditional or not, and I will crack it quickly."

And every time the GPU pipeline stalls because you were executing non-optimal tasks on it, all those threads are sitting twiddling their thumbs, which is like losing man-years of work you could have been applying to a better-suited problem, with no stalls at all.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ This is a really good answer and very insightful, thanks! So, it sounds like parallel CPUs would be the best choice for maximizing culling efficiency? \$\endgroup\$ – Time4Tea Mar 10 at 14:00
  • 1
    \$\begingroup\$ @Time4Tea You're welcome. Yes, at the end of the day, highly parallel CPUs are the long term vision of the PU market, yes. But as an engineer, you will know that no design can be "all things to all people". Or, maybe it can, but the price to own such will be very high. It's the relatively simplistic design of the modern GPU (as compared with CPUs) that makes it so cost effective; whereas CPUs with similar numbers of cores to GPUs, remain very costly. By deeply specialising the purpose of a thing (GPU), you can get major (and cheap) wins on efficiency. \$\endgroup\$ – Engineer Mar 10 at 14:28
1
\$\begingroup\$

To add to Engineer's answer the reason you can't easily parallelize culling is because it's not 'embarrassingly parallel'. If you know the view frustum does not pass x = 5 then you can eliminate everything that does not pass that line pretty easily. And there are even algorithms to do this using an octree and quadtree.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.