Daemon
Daemon copied to clipboard
Alternate lazy shader loading implementation
Right now we have 3 kinds of GLSL shader loading implementation (r_lazyShaders
):
- 0: build all shaders at game start before reaching the main menu (old default): it builds everything before displaying something useful and the user even don't know what's happening, the main menu may not be reachable if an advanced shader doesn't work even if unused by the main menu.
- 1: build shaders on demand until map loads, then build everything else at map load (current default) make sure only the shaders required to display the main menu are built before displaying the main menu, makes fast game load, and fast preset selection in main menu, makes possible to select a lower preset in main menu a shader would fail later at map load,
- 2: build all shaders on demand, makes sure no unused shader is built, a shader may be built while playing the game the first time the texture requiring it is displayed, producing stuttering
Option 1 is a good enough trade-off, but we still build many shaders for nothing. For example we will build the relief mapping and the deluxe mapping permutations even when loading a Tremulous map without such feature.
With option 1 the engine will also build any shader permutation for unused features, for example if we merge #258 that makes possible to generate normal maps from height maps at render time if normal maps are missing, that feature and all the permutations (with or without deluxe map, with lightmap, with grid lighting…) will be built even if there is no asset missing a normal map in the currently played map.
With 0.55, the engine actually selects the rendering function at q3shader load time, meaning we may be able to just implement a loop that would render all the textures on some unseen framebuffer at map load time, triggering the GLSL shader build. That means such lazy shader loading would exhaustively build all required GLSL shaders at map load time, without missing used ones, and without building unused permutations.