0

I've been making a simple Space Invaders clone that uses Vulkan to draw sprites to the screen.

Pushing up the number of invaders, I end up with a lot of sprites.

Reflecting on what (I think) I know about GPUs, if these sprites where all batched together, then the output from the Geometry Shader stage could be sent out to the rasterizers in whatever order. However, with all of my little individual sprites, it feels like not only each triangle, but each pair of triangles making up one of my sprites will have to wait for the previous pair of triangles to have been rasterized so that things don't flicker (I have no idea how this works: I don't understand how the GPU keeps track of what should be drawn first, when all the sprites are being processed in parallel).

It feels like rasterization will be extremely slow, as each quad needs to wait for the last one to be rasterized. Can anyone tell me if this is, in fact, the case? If so, then why does it seem to be relatively cheap in engines like Unreal to have lots of 2d particles being displayed? Surely they would also create the same kind of rasterization bottleneck, or they'd flicker?

CromfCromf
  • 49
  • 3
  • 1
    "*I've been making a simple Space Invaders clone that uses Vulkan to draw sprites to the screen.*" Then it's not going to be a problem. Even an integrated GPU can handle rendering at least 1,000 times the number of sprites that Space Invaders drew. "*the output from the Geometry Shader stage*" Why are you using a Geometry Shader? – Nicol Bolas Sep 18 '22 at 17:40
  • 1
    "*each pair of triangles making up one of my sprites will have to wait for the previous pair of triangles to have been rasterized so that things don't flicker*" What would cause flickering? I don't understand the thinking here. – Nicol Bolas Sep 18 '22 at 17:41
  • @NicolBolas Re. the flickering: my current understanding is that for each of my many sprites, the vertex shader stage etc. can run in parallel, and on one frame Invader A's info might be ready to send of to the rasterization stage before Invader B, and the opposite might be the case the next frame. I thought that, without a z-buffer or whatever, this would lead to flickering with the sprites being drawn in different orders from one frame to the next, unless one sprite was somehow able to wait for the previous one, as seems to be the case. – CromfCromf Sep 18 '22 at 17:57
  • 1
    I suggest you read this: https://fgiesen.wordpress.com/2011/07/09/a-trip-through-the-graphics-pipeline-2011-index/ particularly part 9 'join phase'. Basically, fragment shaders can happily run in parallel and out of order, then there is another fixed hardware stage that corrects the ordering and handles blends. – Columbo Sep 19 '22 at 14:25
  • @Columbo this makes sense of everything! Thank you, this is by far the best explanation of the pipeline I've seen. – CromfCromf Sep 21 '22 at 08:02

0 Answers0