Here’s a question that comes up a lot. According to the spec sheet, the RSX in the PS3 has something like 250 million triangles per second. Then, you can do the math. If we are hitting 30 fps, then we in theory get 8.3m triangles per frame. The resolution of a 720p display is 1280×720, or 921,600 pixels. That means we get about 9 triangles per pixel. At the top is a screenshot from Uncharted 2, and clearly we aren’t getting 9 triangles per pixel. So what gives.
1. Spec Sheets are Meaningless.
The first thing you should know is that when a GPU spec sheet says “x triangles per second” they are talking about the simplest possible triangle you can draw. When they calculate those numbers, they assume that the vertex shader is doing nothing. In real games though, the vertex shader has to do actual work. For a typical normal-mapping shader, the vertex shader needs to calculate postions, normals, binormals, and tangents. If you are doing skinning calculations, that’s more work that you have to do. In other words, if you want to draw any kind of “real” triangle, you won’t get anywhere close to the maximum number of triangles that the spec sheet says.
2. Pass Times.
In a real frame, we aren’t spending all of our time drawing triangles in the scene. We have many passes where we don’t draw any triangles.
That image is from my GDC talk and shows the timeline for the scene. If you want to know what they mean, check out my presentation at the GDC vault. You can also click it for higher res. Anyways, the first 6 lines show what the SPUs are doing. The next line labeled GPU is what the GPU is doing.
On the GPU line, that purple block that takes about 7ms at the start renders the depth and normal. Also, that yellow block that takes about 8ms is the standard pass where we do most of the drawing. Those two passes happen for every object that we draw in the scene. In the rest of the frame, we are doing other passes such as shadows, particles, fog, and fullscreen copies. So we don’t actually have 33ms to draw all these traingles. In the standard pass, we only have 8 ms to draw all the triangles.
3. Pixel Shading
Next up, there is a cost of drawing really small triangles. In particular, you might think that drawing lots of triangles is bad because of the cost of processing all those vertices. The real cost is pixel shading. You would think that drawing 1 triangle with 25 pixels would cost just as much pixel shading as 25 triangles with one pixel each. In reality, GPUs are designed to render many pixels from a single triangle. So if your triangle is really tiny, the GPU is spending time rendering pixels that eventually get discarded. That’s the real cost. If you have complicated pixel shaders, and you draw lots of triangles, then you will get slowed down by your pixel shading.
That’s one thing that everyone should know. We have a fundamental tradeoff between pixel shading and how many triangles we draw. If we wanted to decrease the complexity of our pixel shaders, we could draw more triangles.
That’s about it. Even though you can theoretically draw many triangles per pixel, if your vertex shader actually does work, you don’t get anywhere close to that number. Our main rendering pass in Uncharted 2 usually takes about 8ms, so we get 8ms worth of triangles, not 33ms worth of triangles. And we have a fundamental tradeoff between triangles and pixel shading. Yes, if we wanted to, we could increase the number of triangles in the game if we wanted to really decrease the quality of the shading.
Now the big question: Will all these get solved on PS4/Xbox 720???