Am considering porting over from XNA to the Stage3D API's (Molehill). So as a performance examination I've implemented sprite-batching, but the performance is not all that great, while with XNA i can easily draw up to 500 000 quads but with my Molehill implementation i can draw around a measly 1000 quads and while a rather dramatic performance difference was expected on the CPU side this is due to being GPU bound.
So currently the implementation is as follows.
set render states let texture be null let batchSize be arbitrary for each sprite in queue if texture is not sprite texture or buffers are full upload vertex data to index buffer upload index data to vertex buffer bind texture draw triangles flush vertex data flush index data add sprite vertices to vertex data add sprite indices to index data end upload remaining vertex data to vertex buffer upload remaining index data to index buffer draw remaining triangles flush data
The bottleneck is uploading the buffers, but as for a better implementation I'm hoping for a discussion here.
One optimization that comes to mind is to persist the index buffer, since the indices are predictable and will always follow the same format. Am going to benchmark that now.
Caching the index buffer had no noticeable performance gains, so in an effort to try to understand where the bottleneck is, I ported it over to C#/XNA, ever so slightly slower than Microsoft's implementation but still has a GPU capacity over 500 times more than the Molehill implementation.
Is Molehill simply an extremely bad abstraction layer?