Rebuilding GLSL shaders that don't need a `vid_restart`
I would like to see a mechanism that can rebuild a GLSL shader without needing a vid_restart.
I assume this would be doable for GLSL shaders not requiring to load any new data.
Not candidates:
-
r_normalMapping(requires shader parsing and image loading) -
r_drawSky(requires shader parsing and image loading) -
r_lightMode(requires bsp loading and image loading)
Candidates:
-
r_toneMapping -
r_colorGrading(as far as I know the way colorGrade images are loaded may make it possible)
We already have some lazy shader compilation mechanism, so maybe we can just invalidate a shader to get it rebuilt.
We may implement a mechanism similar to Cvar::Latch(), to register shader cvars with their related GLSL shader, like that:
Cvar::Shader( r_toneMapping, gl_cameraEffectsShader );
When r_toneMapping would be modified, some code would invalidate gl_cameraEffectsShader to trigger a rebuild.
Do note that I'm in the process of reworking shader loading/building to a substantial degree to make it faster and fix a few issues, so any actual changes here shoud be done after that.
Yes, don't worry I have this in the back of my mind since years, but I thought it would be the right time to share the thought.
We already have some lazy shader compilation mechanism, so maybe we can just invalidate a shader to get it rebuilt.
That's a nice idea. Maybe a simple Cvar::Callback to unload the affected shaders could really work. (Can we NUKE r_smp? It would be awfully annoying to have to sync the thread in the callback.)