EntityComponentSystems and Bindless Graphics

I recently found out about Entity Component Systems(ECS) and instantly fell in love. There are two great Cinder Blocks available, Hperigo’s Cinder-ecs block, and sosolimitied’s EntityX samples
I’m personally using sosolimitied’s EntityX block as it looked a little more refined but Hperigo’s was an excellent read through when learning about designing your own and a little more Cinder-infused… thought I’d share…
However… I was also researching up on Nvidia’s bindless graphics and command-list and getting my mind blown…powerful stuff. Correct me if I’m wrong, but bindless graphics and command-list design looks as though they go extremely hand-in-hand with ECS. I’m assuming that if this is correct, than it’s not by any accident. So I am wondering this…
Are my predictions correct? And what would it take to implement a bindless format into Cinder? I can look at it again… my brain was mush after code overload, but it seems as though it would be possible to conclude the usual cinder pipeline, but switch classes out with a bindless equivalent… making it pretty simple to adjust. When I get a chance, I was going to try to implement a working bindless example with cinder but I thought it would be nice to get a couple opinions before diving in the deep end…
Any thoughts?

1 Like

My two cents:

Entity Component Systems allow for better separation of logic and data, making it a bit easier to split your work into tasks that run on different threads. A smart scheduler may even handle the assignment of tasks to CPU cores for you, which could greatly improve performance on the CPU side.

Your tasks can then build command lists, write data to bindless buffers etc. and when done you tell the GPU to start executing the commands. By then, it will have all the data it needs and no involvement of the CPU is required any longer. It’s close to the ideal situation where one frame is prepared on the CPU, one frame is ‘in flight’ on the GPU and one frame is currently displayed.

So: yes, the two techniques go well hand in hand. With the caveat that it will require additional systems (for memory management and task-based scheduling, among others) and a substantial amount of engineering and testing on your end to make the most of it.

-Paul

1 Like

That’s what I thought… I neeeeed that… thanks Paul. I didn’t quite think of separate cores or memory management or task scheduling… Ill post any progress but I’m prob gonna start small and simple to start familiarizing myself with it all… if anyone would like to join in… I think this could really push Cinder to a heavier level…

Look for keywords like “job system” or “work stealing” to find more information about these smart schedulers. Warning: they are very tricky to implement.

1 Like

I went ahead and got NVidia’s BindlessApp sample working in Cinder to help me learn bindless graphics. the sample is working great! Super impressive and I haven’t even gotten to the commandlists or multithreading examples yet… but I did do a fair share of research this week… can’t wait to make a proper followup.
Anyways, is there anything in this Bindless sample that Cinder already handles internally to simplify and sweeten up the code? For example, it would be nice to switch the Mesh.h class with a native Cinder class if it’s cleaner and can bind easier…
It looks as though, however, if I’m not mistaken, that the nature of bindless graphics dumps most of the data onto the GPU and leaves it there… so most of Cinder’s mesh and rendering classes don’t really pertain to a bindless systems, its all Gluints and simple ids to reference GPU locations… right?.. So Cinder’s classes may be a bit bulky for the tasks at hand… question mark…? Again, this would make bindless data excellent for ECS but probably a whole thing entirely from Cinder’s batch workflow…?
I’m using a GLAD Cinder branch for gl extension support and I made a define to switch between ImGui or params if anyone wants to get this sample running and throw some Cinder-fying tweaks on it. Can’t wait to use this technique with my own ideas! Cheers.

2 Likes

I almost have the NVidia commandlist example working in Cinder but I think I’m having an issue with the shader compile…
I was having problems including the common.h shader asset file with the sample’s compileProgram function, so I used Cinder’s native “createShader” function and returned a Handle()… but it’s not working either. I think it might have something to do with glCompileShaderIncludeARB
… Also, I tried making an Fbo to blit to from the scenefbo, but it only works if I blit-to-screen using address 0, which isn’t optimal and I have no idea why the latter wouldn’t work… any ideas? I can see that it’s using my gpu and it’s doing something, but right now I’m not getting any rendering results… sooo close.