Daemon
Daemon copied to clipboard
Make feature disablement more consistent and move some compute at stage configuration
The PR was split, please review those PR before reviewing this one:
- https://github.com/DaemonEngine/Daemon/pull/820
- https://github.com/DaemonEngine/Daemon/pull/821
- https://github.com/DaemonEngine/Daemon/pull/822
- https://github.com/DaemonEngine/Daemon/pull/823
- https://github.com/DaemonEngine/Daemon/pull/824
Once those other PRs are merged, the remaining commits to review will be:
-
tr_shade: Render_generic() calls Render_generic2D() if 2D -
tr_shade,tr_shader: set colorGen and alphaGen only once
Original message:
- Make feature disablement more consistent: various combinations of disabled
r_precomputedLightwhere wrong. - Make possible to load deluxe maps even if light mapping is disabled, as deluxe mapping with grid lighting is possible.
- Do not load lightgrid if precomputed lighting is disabled, the same way lightmap loading is already disabled.
- Call
Render_lightMapping()on every related shader stages because that function knows how to render in all cases. -
Render_generic()callsRender_generic2D()if 2D, This allows to move the function fromTess_StageIteratorGeneric()which means many tests fromTess_StageIteratorGeneric()can be moved to shader stage configuration. - Select shader stage render function only once. Introduce
SetShaderStageRenderers()and call it at shader stage configuration. Not only factorise the code, but makes sure the Render function as selected once and only once, if possible when finalizing the shader stage, instead of running it on every frame - Set
colorGenandalphaGenonly once. Factorise the code, do it only once per shader stage, and do it when finalizing the shader stage if possible. - Make
r_precomputedLightinga cheat cvar. Disabling this cvar disables all precomputed shadows and then makes everything fullbright, which gives an unbalanced advantage by making everything visible.
The two biggest points would be summarized that way:
- Disabling
r_precomputedLightingnow works correctly, and it is now a cheat cvar (disables all precomputed lights and then shadows). - Some code to select the
Render_*function and sets somecolorGenandalphaGenoptions are now run only once for the whole game time instead of doing the related computations on every frame. This unifies manyRender_*function signatures to be the same. It means that on every frame for every shader stage the code now just runs the related function and that's all. The code that is optimized wasn't super heavy on CPU (it was mostly tests) but that design bothered me for a long time, and the rewrite also brings some factorisation and code deduplication, also reducing line count. Less code to read for humans, less code to execute for CPUs.
I'm splitting the PR.
Please review those PR before reviewing this one:
- https://github.com/DaemonEngine/Daemon/pull/820
- https://github.com/DaemonEngine/Daemon/pull/821
- https://github.com/DaemonEngine/Daemon/pull/822
- https://github.com/DaemonEngine/Daemon/pull/823
- https://github.com/DaemonEngine/Daemon/pull/824