Make sure shaders are only loaded once at startup, fix #386

this *shouldn't* matter, but due to some Mesa bug is does:
If the shaders have been loaded already (with R_LoadARBProgram()),
then loading them again (like from the `reloadARBprograms` console cmd
or as it happens if the `r_gammaInShader` has been modified) will
cause glitches with the open source radeonsi driver (maybe also with
others? at least the open source intel driver seems unaffected).
As r_gammaInShader was marked as modified at startup (before the shaders
were even loaded) they were loaded twice: First as expected when OpenGL
is initialized, then again in R_CheckCvars() which is executed each
frame. Marking as at not modified in R_InitOpenGL() prevents this and
thus works around the bug.
However this means that changing r_gammaInShader at runtime will still
trigger this bug (while with non-broken drivers it switches seamlessly
between gamma in shader and gamma in hardware without a vid_restart).
This commit is contained in:
Daniel Gibson 2021-06-24 18:37:14 +02:00
parent 8747ee63d3
commit 277dbf89f1

View file

@ -734,7 +734,13 @@ void R_InitOpenGL( void ) {
R_InitFrameData();
// Reset our gamma
R_SetColorMappings();
r_gammaInShader.ClearModified();
if ( r_gammaInShader.GetBool() ) {
common->Printf( "Will apply r_gamma and r_brightness in shaders (r_gammaInShader 1)\n" );
} else {
common->Printf( "Will apply r_gamma and r_brightness in hardware (possibly on all screens; r_gammaInShader 0)\n" );
R_SetColorMappings();
}
#ifdef _WIN32
static bool glCheck = false;