🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Calling OpenGL buffer initialization between frames

Started by
0 comments, last by PixelArtDragon 2 years, 2 months ago

I'm working on making my rendering code multi-threaded by using a rendering queue into which I place various rendering calls (enqueued by other threads), which then can be ordered in a preprocessing step to eliminate unnecessary shader program and uniform switches.

I've been wondering how to integrate loading code into this design to be able to load meshes and textures without impacting rendering (e.g. to be able to load graphics without a loading screen). My approach right now is (assuming the loading into RAM happened asynchronously and already finished), is to enque a “load data” command (create buffers, blit data) into the rendering queue (in a way that it orders after the heavier rendering code has finished for that frame).

Another approach (which I only thought of while writing this) is to avoid creating new buffers at runtime at all- use a pool of pre-generated buffers. This way, the only load command would be to copy the data from RAM to the GPU (and those could be ordered to be early in the rendering queue so that the data would have finished being sent to the GPU before that object's render call happened). I might save any potential overhead of the generate buffers commands (which I can't imagine would be particularly fast considering it looks like it's a synchronous command). Downside is, I'd need to know ahead of time how many of what kinds of buffers I can feasibly support.

Are either of these approaches any good? What might be the pros and cons of them? And are there any other options I might want to consider instead?

This topic is closed to new replies.

Advertisement