About Koko's Entity Component System and Performance of Sprite Batches


After thinking about, "How can I use all the available resources" and "How to implement a decent Entity Component System", I came with a new idea about how to mange it, I splitted the components into two different fields, Shared Components and Simple Components, the diference among both, is, while a Shared Component can be legally be used by two different entities, a Simple Components can only be used by one entity, so if you have a shader that is the same for different entities you, your entity can easly use that shader (and of course update stuff if needed). By the moment I have created only two Shared Components, the Shared Shader, and the Shared Buffers, I already explained the Shared Shader, so I will try to show how Shared Buffers works, and why it could be for performance. First of all, when you need to draw something you need several buffers (those buffers are allocated memory in the gpu), you upload the geometry to those buffers and then you draw them, but what happens if you have a dynamic geometry, I mean you don't know what will be drawn, just like and a sprite batch, it batches all the needed elements and send them to the buffers, but something that I thought wille making sprite batch class is that the buffer data is always flushed when a frame is drawn, after that I decided to make the shared buffers, where several batches share the same buffers, and only few memory is allocated; so having a lot of batches or text drawers(who are a hidden sprite batcher) will have a very small impact.


This is my attempt trying to explain the mess I created.

P.D. I Don't know how to make a good looking post I'm sorry.

Cluck-cluck-cluck!


Leave a comment

Log in with itch.io to leave a comment.