The rendering pipe in Stingray is completely data-driven, meaning that everything from which GPU buffers (render targets etc) that are needed to compose the final rendered frame to the actual flow of the frames is described in the render_config file - a human readable json file. I have covered this in various presentations [1,2] over the years so I won’t be going into more details about it in this blog post, instead I’d like to focus on a new feature that we are rolling out in Stingray v1.5 - Render Config Extensions.
As Stingray is growing to cater to more industries than game development we see lots of feature requests that don’t necessarily fit in with our ideas of what should go into the default rendering pipe that we ship with Stingray. This has made it apparent that we need a way of doing deep integrations of new rendering features without having to duplicate the entire render_config file.
This is where the render_config_extension files comes into play. A render_config_extension is very similar to the main render_config except that instead of having to describe the entire rendering pipe it appends and inserts different json blocks into the main render_config.
When the engine starts the boot ini-file specifies what render_config to use as well as an array of render_config_extensions to load when setting up the renderer.
The array describes the initialization order of the extensions which makes it possible for the project author to control how the different extensions stacks on top of each other. It also makes it possible to build extensions that depends on other extensions.
A render_config_extension consists of two root blocks: append and insert_at:
The append block is used for everything that is order independent and allows you to append data to the following root blocks of the main render_config:
- shader_libraries – lists additional shader_libraries to load
- render_settings – add more render_settings (quality settings, debug flags, etc.)
- shader_pass_flags – add more shader_pass_flags (used by shader system to dynamically turn on/off passes)
- global_resources – additional global GPU resources to allocate on boot
- resource_generators – expose new resource_generators
- viewports – expose new viewport templates
- lookup_tables – append to the list of resource_generators to execute when booting the renderer (mainly used for generating lookup tables)
One thing to note about extending these blocks is that we currently do not do any kind of name collision checking, so using a prefix to mimic a namespace for your extension is probably a good idea.
The insert_at block allows you to insert layers and modifiers into already existing layer_configurations and resource_generators, either belonging to the mainrender_config file or a render_config_extension listed earlier in the render_config_extensions array of engine boot ini-file.
The object names under the insert_at block refers to extension_insertion_points listed in the main render_config file or one of the previously loadedrender_config_extension files. We’ve chosen not to allow extensions to inject anywhere they like (using line numbers or similar crazyness), instead we expose a bunch of extension “hooks” at various places in the main render_config file. By doing this we hope to have a somewhat better chance of not breaking existing extensions as we continue to develop and potentially do bigger refactorings of the default render_config file.
This extension mechanism is somewhat of an experiment and we might need to rethink parts of it in a later version of Stingray. We’ve briefly discussed a potential need for dealing with versioning, i.e. allowing extensions to explicitly list what versions of Stingray they are compatible with (and maybe also allow extensions to have deviating implementations depending on version). Some kind of enforced name spacing and more aggressive validation to avoid name collisions have also been debated.
In the end we decided to ignore these potential problems for now and instead push for getting a first version out in 1.5 to unblock plugin developers and internal teams wanting to do efficient “deep” integrations of various rendering features. Hopefully we won’t regret this decision too much later on. ;)
 Flexible Rendering for Multiple Platforms (Tobias Persson, GDC 2012)
 Benefits of data-driven renderer (Tobias Persson, GDC 2011)