Improving performance of rendering continuously updated meshes

Hey Embers,

I’m working with some continuously generated 3D Text meshes that I am rendering on-screen. I currently generate them as a geom object in a separate thread, then pass them back to the main thread.

To render them, I’ve tried two implementations thus far:

  1. Creating a new Batch object when the Geom arrives.
  2. Pre-allocating a number of Batch objects, and then creating a new VboMesh object when the geom arrives with which to update an existing Batch.

Both approaches cause a brief visible pause in Debug mode. In Release it runs without significant visible hitching. Either way, I’m pretty set on eliminating the hitching in Debug mode. But I’m not exactly sure how to best leverage Cinder to do this.

I believe maintaining a single Batch and updating it with all incoming mesh data is probably fastest, but I am currently just pursuing a solution where I maintain several Batch objects. I.e. one per incoming mesh.

So I’ve created a set of pre-allocated Batch objects, but I don’t know how to easily update them with a geom. I’ve only spotted approaches that require creating a VboMesh which also makes the execution hitch.

I hope someone can help point me in the right direction? I.e. is there a easy way to use the geom data to write straight into a Batch / VboMesh?

Cheers,

Gazoo

Can you generate/modify the meshes on the gpu? Probably that would be faster than uploading the new data all the time.

If you’d like to update the data you can try getting the Vbo's of the VboMesh and call bufferData to upload from the cpu.

-Gabor

1 Like

A GPU based solution is possible, but that approach would require a significant amount of additional work. Not to mention be far harder to debug.

Per your advice I’ve started looking into using bufferData(), I found that only the LevelOfDetailBasicApp samples uses it. It would seem I likely need to create a VBO using the GL_DYNAMIC_DRAW setting. Apart from that I’m still looking at the code.

How to properly upload a custom mesh with positional and normals, perhaps even color, is still a bit beyond me, so if anyone has any additional advice on how to do this - I’m all ears. The example creates a VBO to a specific size, where as my mesh sizes will vary. There’s probably a reasonable maximum size, which I’d imagine the VBO should be initialized as, but then how to update only some of the data I’m not sure. Do I just set the vertices data I won’t use to 0? Hmm.

I’ll be trying my best to work out how to use the bufferData() in the mean time.

Tiny update: VboMeshGeomTarget looks interesting and uses a number of related data-structures. Could perhaps be of use…

Tiny update 2: If this link is to be believed, perhaps just re-upping all the data via copyBuffer and orphaning the old one is the way to go.

Cheers,
Gazoo

Not to be glib, but a performance problem that only exists in debug is not a problem at all. Assuming this isn’t an educational exercise my advice is to count your lucky stars and move on to a problem that actually needs to be solved.

Failing that, perhaps see if you can generate your geometry once and feed it texture / buffer based displacements ala houdini’s VAT’s.

2 Likes

not sure if this is the solution and I’ve yet to try it in cinder, but it looks awesome… haven’t read this in a bit but your post reminded me of it.

https://developer.download.nvidia.com/opengl/tutorials/bindless_graphics.pdf

Let me know if you get this working on cinder. You might have to use the cinder GLAD build and import newer OpenGL extensions…

2 Likes

@lithium I appreciate your glib’ness, and generally agree with your opinion. So far, I’ve not only been able to execute, but also evaluate and with reasonable responsiveness interact with my application in Debug mode. Admittedly, it’s starting to get to the point where evaluating its visual output is becoming more difficult, and I’d agree that a solution is simply to stop expecting to do this Debug mode, and instead rely on Release mode entirely.

For now - you may well be right that the solution is just do that and solve something that doesn’t have such an easy solution.

The ‘is this actually worth solving’ discussion aside - I was a little surprised to find Cinder’s limited support in terms of directly using a geom to overwrite/update a Vbo without creating a new one. I guess in 99% of cases the resources are just all pre-loaded in some manner.