From 55abc3f7bb0518b11a8c654d33d6050de353643f Mon Sep 17 00:00:00 2001 From: Jupeyy Date: Wed, 18 Aug 2021 12:03:42 +0200 Subject: [PATCH] Make fallback stronger and safer --- src/engine/client/backend/opengl/backend_opengl.cpp | 4 +++- src/engine/client/backend_sdl.cpp | 3 +++ src/engine/shared/config_variables.h | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/engine/client/backend/opengl/backend_opengl.cpp b/src/engine/client/backend/opengl/backend_opengl.cpp index aa96b0b17..a3aa460d1 100644 --- a/src/engine/client/backend/opengl/backend_opengl.cpp +++ b/src/engine/client/backend/opengl/backend_opengl.cpp @@ -1741,12 +1741,14 @@ bool CCommandProcessorFragment_OpenGL2::Cmd_Init(const SCommand_Init *pCommand) glUseProgram(0); } - if(g_Config.m_Gfx3DTextureAnalysisDone == 0) + if(g_Config.m_Gfx3DTextureAnalysisDone == 0 || str_comp(g_Config.m_Gfx3DTextureAnalysisRenderer, pCommand->m_pRendererString) != 0 || str_comp(g_Config.m_Gfx3DTextureAnalysisVersion, pCommand->m_pVersionString) != 0) { AnalysisCorrect = IsTileMapAnalysisSucceeded(); if(AnalysisCorrect) { g_Config.m_Gfx3DTextureAnalysisDone = 1; + str_copy(g_Config.m_Gfx3DTextureAnalysisRenderer, pCommand->m_pRendererString, sizeof(g_Config.m_Gfx3DTextureAnalysisRenderer) / sizeof(g_Config.m_Gfx3DTextureAnalysisRenderer[0])); + str_copy(g_Config.m_Gfx3DTextureAnalysisVersion, pCommand->m_pVersionString, sizeof(g_Config.m_Gfx3DTextureAnalysisVersion) / sizeof(g_Config.m_Gfx3DTextureAnalysisVersion[0])); } } } diff --git a/src/engine/client/backend_sdl.cpp b/src/engine/client/backend_sdl.cpp index 7ac5167be..eb0d2b47b 100644 --- a/src/engine/client/backend_sdl.cpp +++ b/src/engine/client/backend_sdl.cpp @@ -347,6 +347,8 @@ static bool BackendInitGlew(EBackendType BackendType, int &GlewMajor, int &GlewM GlewPatch = 0; return true; } +// Don't allow GL 3.3, if the driver doesn't support atleast OpenGL 4.5 +#ifndef CONF_PLATFORM_WINDOWS if(GLEW_VERSION_4_4) { GlewMajor = 4; @@ -389,6 +391,7 @@ static bool BackendInitGlew(EBackendType BackendType, int &GlewMajor, int &GlewM GlewPatch = 0; return true; } +#endif if(GLEW_VERSION_3_0) { GlewMajor = 3; diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index ec5b88a7e..2b68431ff 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -403,6 +403,9 @@ MACRO_CONFIG_INT(GfxOpenGLPatch, gfx_opengl_patch, 0, 0, 10, CFGFLAG_SAVE | CFGF MACRO_CONFIG_INT(GfxOpenGLTextureLODBIAS, gfx_opengl_texture_lod_bias, -500, -15000, 15000, CFGFLAG_SAVE | CFGFLAG_CLIENT, "The lod bias for OpenGL texture sampling multiplied by 1000") MACRO_CONFIG_INT(Gfx3DTextureAnalysisDone, gfx_3d_texture_analysis_done, 0, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Analyzed, if sampling 3D/2D array textures was correct") +MACRO_CONFIG_STR(Gfx3DTextureAnalysisRenderer, gfx_3d_texture_analysis_renderer, 128, "", CFGFLAG_SAVE | CFGFLAG_CLIENT, "The renderer on which the analysis was performed") +MACRO_CONFIG_STR(Gfx3DTextureAnalysisVersion, gfx_3d_texture_analysis_version, 128, "", CFGFLAG_SAVE | CFGFLAG_CLIENT, "The version on which the analysis was performed") + MACRO_CONFIG_INT(GfxDriverIsBlocked, gfx_driver_is_blocked, 0, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "If 1, the current driver is in a blocked error state.") #if !defined(CONF_PLATFORM_MACOS) MACRO_CONFIG_INT(GfxEnableTextureUnitOptimization, gfx_enable_texture_unit_optimization, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Use multiple texture units, instead of only one.")