Skip to content

Improve lazy shader loading #1656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 4, 2025

Conversation

VReaperV
Copy link
Contributor

Implements #1294

Previously, when r_lazyShaders 1 was used, it would simply load all of the possible shaders with the current graphics settings, and without deform shaders.

With this change, it will instead mark shaders that are used for BSP and model surfaces for building, which will be done in RE_EndRegistration(). Skins are also loaded (the variants with skeletal animation are always loaded because we don't know if an MD5 model will need them later).

This greatly reduces the amount of shaders built, and allows building deform shaders at map load. For example, on plat23 with pretty much all shader stuff enabled (except liquid shaders and static reflections), including material system, it went down from 433 shaders built at map load to just 28. I did know that a bunch of the shaders were unused, but this is still a surprising amount less.

Also made it so when a shader is loaded outside of BuildAll() (i. e. in BindProgram() or GetProgram()), the engine will print information about that.

From my testing, there are only a few shaders that this system doesn't get at map load, I'll see if I can make those load at the start as well in a different pr.

Previously, when `r_lazyShaders 1` was used, it would simply load all of the possible shaders with the current graphics settings, and without deform shaders.

With this change, it will instead mark shaders that are used for BSP and model surfaces for building, which will be done in `RE_EndRegistration()`. Skins are also loaded (the variants with skeletal animation are always loaded because we don't know if an MD5 model will need them later).

This reduces the amount of shaders built, and allows building deform shaders at map load.
@VReaperV VReaperV added T-Improvement Improvement for an existing feature A-Renderer T-Performance labels Apr 29, 2025
@VReaperV VReaperV force-pushed the lazy-shader-load-improve branch from 04c4163 to 223b7ae Compare May 2, 2025 20:10
@slipher
Copy link
Member

slipher commented May 4, 2025

LGTM

@VReaperV VReaperV merged commit ab2349a into DaemonEngine:master May 4, 2025
9 checks passed
@VReaperV VReaperV deleted the lazy-shader-load-improve branch May 4, 2025 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Renderer T-Improvement Improvement for an existing feature T-Performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants