From 685c6eb8ad3d3a56ad284d36916076057b95f472 Mon Sep 17 00:00:00 2001 From: slipher Date: Sun, 31 Aug 2025 13:27:08 -0500 Subject: [PATCH 1/2] Correctly set glConfig.relectionMappingAvailable glConfig.reflectionMappingAvailable was set after shaders are loaded, so gl_reflectionShader was not loaded when it should be. Set it in EnableAvailableFeatures(). Also it could only be set to true; if you turned off the cvar the next map change would not set it to false. Fixes the bug that r_showCubeProbes causes a crash (due to null gl_reflectionShader) if reflection mapping was not enabled in the previous renderer load. --- src/engine/renderer/tr_init.cpp | 24 ------------------------ src/engine/sys/sdl_glimp.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/engine/renderer/tr_init.cpp b/src/engine/renderer/tr_init.cpp index 3a6dba3583..3bcf0423ae 100644 --- a/src/engine/renderer/tr_init.cpp +++ b/src/engine/renderer/tr_init.cpp @@ -1439,30 +1439,6 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p tr.lightMode = lightMode_t::VERTEX; } - if ( r_reflectionMapping.Get() ) { - glConfig.reflectionMappingAvailable = true; - - if ( !r_normalMapping->integer ) { - glConfig.reflectionMappingAvailable = false; - Log::Warn( "Unable to use static reflections without normal mapping, make sure you enable r_normalMapping" ); - } - - if ( !r_deluxeMapping->integer ) { - glConfig.reflectionMappingAvailable = false; - Log::Warn( "Unable to use static reflections without deluxe mapping, make sure you enable r_deluxeMapping" ); - } - - if ( !r_specularMapping->integer ) { - glConfig.reflectionMappingAvailable = false; - Log::Warn( "Unable to use static reflections without specular mapping, make sure you enable r_specularMapping" ); - } - - if ( r_physicalMapping->integer ) { - glConfig.reflectionMappingAvailable = false; - Log::Warn( "Unable to use static reflections with physical mapping, make sure you disable r_physicalMapping" ); - } - } - backEndData[ 0 ] = ( backEndData_t * ) ri.Hunk_Alloc( sizeof( *backEndData[ 0 ] ), ha_pref::h_low ); backEndData[ 0 ]->polys = ( srfPoly_t * ) ri.Hunk_Alloc( r_maxPolys->integer * sizeof( srfPoly_t ), ha_pref::h_low ); backEndData[ 0 ]->polyVerts = ( polyVert_t * ) ri.Hunk_Alloc( r_maxPolyVerts->integer * sizeof( polyVert_t ), ha_pref::h_low ); diff --git a/src/engine/sys/sdl_glimp.cpp b/src/engine/sys/sdl_glimp.cpp index 1d484a513c..5d85d20d58 100644 --- a/src/engine/sys/sdl_glimp.cpp +++ b/src/engine/sys/sdl_glimp.cpp @@ -2812,6 +2812,30 @@ static void GLimp_EnableAvailableFeatures() // This will be enabled later on by R_BuildCubeMaps() glConfig.reflectionMapping = false; + glConfig.reflectionMappingAvailable = r_reflectionMapping.Get(); + if ( glConfig.reflectionMappingAvailable ) + { + if ( !r_normalMapping->integer ) { + glConfig.reflectionMappingAvailable = false; + Log::Warn( "Unable to use static reflections without normal mapping, make sure you enable r_normalMapping" ); + } + + if ( !r_deluxeMapping->integer ) { + glConfig.reflectionMappingAvailable = false; + Log::Warn( "Unable to use static reflections without deluxe mapping, make sure you enable r_deluxeMapping" ); + } + + if ( !r_specularMapping->integer ) { + glConfig.reflectionMappingAvailable = false; + Log::Warn( "Unable to use static reflections without specular mapping, make sure you enable r_specularMapping" ); + } + + if ( r_physicalMapping->integer ) { + glConfig.reflectionMappingAvailable = false; + Log::Warn( "Unable to use static reflections with physical mapping, make sure you disable r_physicalMapping" ); + } + } + /* Intel GMA 3 only has 4 tex indirections, which is not enough for some shaders. For example blurX requires 6, contrast requires 5, motionblur requires 5… For comparison, ATI R300, R400 and R500 have 16 of them. We don't need a finer check as early R300 From 533b802ac80473bd2aafeda14148c1be00618a6e Mon Sep 17 00:00:00 2001 From: slipher Date: Sun, 31 Aug 2025 13:31:59 -0500 Subject: [PATCH 2/2] Disable reflection mapping if hardware insufficient If a required feature of normal/deluxe/specular mapping was disabled for a reason other than the cvar, glConfig.reflectionMappingAvailable must be set to false. --- src/engine/sys/sdl_glimp.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/engine/sys/sdl_glimp.cpp b/src/engine/sys/sdl_glimp.cpp index 5d85d20d58..19d21f407d 100644 --- a/src/engine/sys/sdl_glimp.cpp +++ b/src/engine/sys/sdl_glimp.cpp @@ -2816,24 +2816,26 @@ static void GLimp_EnableAvailableFeatures() if ( glConfig.reflectionMappingAvailable ) { if ( !r_normalMapping->integer ) { - glConfig.reflectionMappingAvailable = false; Log::Warn( "Unable to use static reflections without normal mapping, make sure you enable r_normalMapping" ); } if ( !r_deluxeMapping->integer ) { - glConfig.reflectionMappingAvailable = false; Log::Warn( "Unable to use static reflections without deluxe mapping, make sure you enable r_deluxeMapping" ); } if ( !r_specularMapping->integer ) { - glConfig.reflectionMappingAvailable = false; Log::Warn( "Unable to use static reflections without specular mapping, make sure you enable r_specularMapping" ); } if ( r_physicalMapping->integer ) { - glConfig.reflectionMappingAvailable = false; Log::Warn( "Unable to use static reflections with physical mapping, make sure you disable r_physicalMapping" ); } + + glConfig.reflectionMappingAvailable = + glConfig.normalMapping && + glConfig.deluxeMapping && + glConfig.specularMapping && + !glConfig.physicalMapping; } /* Intel GMA 3 only has 4 tex indirections, which is not enough for some shaders.