Wednesday, January 16, 2013

Minimising GPU batches (+500 pts)

Remember about minimizing batches?

Profiling webGL and Javascript is a pain.  There is such a disconnect, and the tooling so non-existent, that its really trial-and-error.

For drawing complex 2D scenes in LD25 I created my own little quad-tree.  In my normal fashion, I stored bounds not points.

Now I want to minimise my batches.  My 2D drawing context concatenates draw ops with the same state into a single draw-op, so if I can just draw all the same bitmaps together I can really minimise the state changes.  I just have to visit the visible rectangles in the right order!

And so I’ve asked on StackOverflow and now I’ve put a+500 bounty on it!

Of course, it wasn’t enough to ask in the abstract.  I ended up creating a little test app to answer the various comments I got.

… and, predictably, the test app does not exhibit the desired behaviour!  Whereas in my complex game scenes it does seem to help to do batching, in the test app it actually helps to draw them out of order.

Go figure!  There’s just such a gap between my Javascript emitting anything and the webGL runtime forwarding it to the GPU that I really don’t know whats going where and what the bottlenecks are.

I have the bounty anyway, despite the test app not really being a good benchmark.  I hope someone does something worth +500points, e.g. offers up a faster R-tree or something.


 ↓ click the "share" button below!