Framebuffer Management

I use the term "framebuffer" with the same meaning as the GL_EXT_framebuffer_object OpenGL extension. A framebuffer is a set of buffers which will be rendered into, with some also being usable as textures.

Managing framebuffers is something I'm about to redesign. The current version in OctoPort has a set number of buffers of various sizes and user-defined formats, and the Effects declare a complete framebuffer, with the format they need, and the size format they need (screen sized or not).

The reason to handle management this way is that the engine chooses which buffers to provide to a given framebuffer, based on current use and the screen space area taken. So a distant light can be given a small set of buffers, but as the player moves toward it, it'll be given a bigger version (the same with a reflecting object).

At one point in time the engine was handling the different size/format buffers using the adaptive cache, but the drawback (in OpenGL at least) was that when one of the buffers of a framebuffer was changing (due to LRU), binding the replacement buffer did cost several milliseconds. The perspective of having even little framebuffers changing per frame with that performance penalty is not appealing at all.

Having some kind of a memory limiter (a manager which would solely make sure the memory budget isn't exceeded) isn't something too interesting either, as it would lead to generating and regenerating buffers now and then, and likely to memory fragmentation.

The two ideas I keep for the FlExtEngine is to have set number of buffers of various sizes (being dependent on the window's size) and of different user-defined formats, and to let a custom RenderingProcess create the required framebuffers. The latter is far less appealing in tersm of design and flexibility, but should be enough for most games. In that case, it would still be a good idea to have a set of framebuffers of different size (but same format) to manage shadow maps.

In the next installment I'll talk about the rendering process, mostly in terms of shading, effects and lighting (including forward and deferred shading).

Discussion

If you want to discuss the article, head on over to the forum thread.