How to handle batching in custom monogame engine

I’m building a simple engine using mono game, in order to port our game. Quick reasoning behind this, is that it’d be easier to write a simple api similar to the one the game is written in, to make porting easier. Currently I’ve gotten so far as implementing the scene graph, and next I’d like to move onto writing a renderer and batcher class before I begin actually porting.

A bit of background, the game is a racing game using a custom psuedo 3d engine, which uses projected quads to create a 3d like world, similar to outrun but with textured quads. The current engine is able to draw the whole gamescene in 3 draw calls, but this is a bit ambitious and I’d be happy enough breaking that into more batches. We did some hacks there to get spine files, sprites and textured quads to all batch together.

Initially I had in mind what I now think is a somewhat naive solution. I figured I’d simply setup a spritebatch, a spinebatch, and use drawuserindices (can’t remember exact api) to handle drawing the quads. Then, when traversing the scene graph, I’d keep store a state for the type of batch we are currently running, and then if I hit something that was not the current batch type, id stop that batch, and start the appropriate batch.

I figured this would probably be good enough for my purposes, but thought I’d better read through the relevant source code in both extended and Nez. But in these frameworks they decided to do a more “proper” solution, for want of a better word. By proper I mean like other implementations I have seen. Seems to me from a quick read of both that they are combining vertices into batches, upto max sprites, where its then flushed.

Where this worries me is that I need to handle these three types, spine, sprite and quad, and how I would actually go about batching all of these (particularly spine worries me here). Are there real flaws in my original approach? and if so are there any examples of other frameworks that include the batching of spine / quad / sprite together ?

Any help much appreciated, and I hope my description of the problem was clear.

In my “engine” I use render bins (lists in fact).

When traversing the scene for culling etc, any object that needs to be rendered is added to one of the render bins.

Once this is finished, rendering is done. The rendering simply iterates over all render bins.
For each render bin the proper state is set (once) and then all the objects in that render bin are rendered. This approach helps minimize state changes.
But note that I still have one draw call per object (I am not merging objects to minimize draw calls).

I can elaborate on this approach if you need me to…

Ah, your solution is something else I had considered, but I really need to squeeze as much performance as I can because a large part of the point of this port is to target low end android devices.

I ended up using both nez and mono game extended as a base to work from. Here’s some results I got from my simple tests:-

pc opengl - 2000 sprites : ~55 fps
kindle 7" 2015 - 2000 sprites : ~32 fps
nexus 7 - 2000 sprites : ~16 fps

This is actually a slight improvement upon using a basic sprite batch without all the scene graph calculations, and just two args, texture and position (deprecated api call). I guess that’s likely due to the overload I used, so can probably consider equivalent performance to sprite batch, so suits my needs. I can quite easily add in quad rendering, but not sure how to handle spine.