From 5341fc37fde68aae653a375471f8654914992707 Mon Sep 17 00:00:00 2001 From: Jupeyy Date: Tue, 13 Dec 2022 19:29:48 +0100 Subject: [PATCH] Minimal changes to default to Vulkan --- src/engine/shared/config.h | 15 ++++++++++++--- src/engine/shared/config_variables.h | 12 +++++++++++- src/game/client/components/menus_settings.cpp | 2 +- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/engine/shared/config.h b/src/engine/shared/config.h index 376d24ef1..5a7bbe574 100644 --- a/src/engine/shared/config.h +++ b/src/engine/shared/config.h @@ -6,6 +6,9 @@ #include #include +// include protocol for MAX_CLIENT used in config_variables +#include + #define CONFIG_FILE "settings_ddnet.cfg" #define AUTOEXEC_FILE "autoexec.cfg" #define AUTOEXEC_CLIENT_FILE "autoexec_client.cfg" @@ -14,9 +17,15 @@ class CConfig { public: -#define MACRO_CONFIG_INT(Name, ScriptName, Def, Min, Max, Save, Desc) int m_##Name; -#define MACRO_CONFIG_COL(Name, ScriptName, Def, Save, Desc) unsigned m_##Name; -#define MACRO_CONFIG_STR(Name, ScriptName, Len, Def, Save, Desc) char m_##Name[Len]; // Flawfinder: ignore +#define MACRO_CONFIG_INT(Name, ScriptName, Def, Min, Max, Save, Desc) \ + static constexpr int ms_##Name = Def; \ + int m_##Name; +#define MACRO_CONFIG_COL(Name, ScriptName, Def, Save, Desc) \ + static constexpr unsigned ms_##Name = Def; \ + unsigned m_##Name; +#define MACRO_CONFIG_STR(Name, ScriptName, Len, Def, Save, Desc) \ + static constexpr const char *ms_p##Name = Def; \ + char m_##Name[Len]; // Flawfinder: ignore #include "config_variables.h" #undef MACRO_CONFIG_INT #undef MACRO_CONFIG_COL diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index 353e741c9..e9282fecb 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -422,12 +422,18 @@ MACRO_CONFIG_INT(ClDemoShowSpeed, cl_demo_show_speed, 0, 0, 1, CFGFLAG_SAVE | CF MACRO_CONFIG_INT(ClDemoKeyboardShortcuts, cl_demo_keyboard_shortcuts, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Enable keyboard shortcuts in demo player") // graphic library -#ifndef CONF_ARCH_IA32 +#if !defined(CONF_ARCH_IA32) && !defined(CONF_PLATFORM_MACOS) +MACRO_CONFIG_INT(GfxGLMajor, gfx_gl_major, 1, 1, 10, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Graphic library major version") +#elif !defined(CONF_ARCH_IA32) MACRO_CONFIG_INT(GfxGLMajor, gfx_gl_major, 3, 1, 10, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Graphic library major version") #else MACRO_CONFIG_INT(GfxGLMajor, gfx_gl_major, 1, 1, 10, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Graphic library major version") #endif +#if !defined(CONF_PLATFORM_MACOS) +MACRO_CONFIG_INT(GfxGLMinor, gfx_gl_minor, 1, 0, 10, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Graphic library minor version") +#else MACRO_CONFIG_INT(GfxGLMinor, gfx_gl_minor, 0, 0, 10, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Graphic library minor version") +#endif MACRO_CONFIG_INT(GfxGLPatch, gfx_gl_patch, 0, 0, 10, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Graphic library patch version") // float multiplied with 1000 @@ -438,7 +444,11 @@ MACRO_CONFIG_STR(Gfx3DTextureAnalysisRenderer, gfx_3d_texture_analysis_renderer, MACRO_CONFIG_STR(Gfx3DTextureAnalysisVersion, gfx_3d_texture_analysis_version, 128, "", CFGFLAG_SAVE | CFGFLAG_CLIENT, "The version on which the analysis was performed") MACRO_CONFIG_STR(GfxGPUName, gfx_gpu_name, 256, "auto", CFGFLAG_SAVE | CFGFLAG_CLIENT, "The GPU's name, which will be selected by the backend. (if supported by the backend)") +#if !defined(CONF_ARCH_IA32) && !defined(CONF_PLATFORM_MACOS) +MACRO_CONFIG_STR(GfxBackend, gfx_backend, 256, "Vulkan", CFGFLAG_SAVE | CFGFLAG_CLIENT, "The backend to use (e.g. OpenGL or Vulkan)") +#else MACRO_CONFIG_STR(GfxBackend, gfx_backend, 256, "OpenGL", CFGFLAG_SAVE | CFGFLAG_CLIENT, "The backend to use (e.g. OpenGL or Vulkan)") +#endif MACRO_CONFIG_INT(GfxRenderThreadCount, gfx_render_thread_count, 3, 0, 0, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Number of threads the backend can use for rendering. (note: the value can be ignored by the backend)") 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.") diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index f5e687bab..9f4dec691 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -1741,7 +1741,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView) char aTmpBackendName[256]; auto IsInfoDefault = [](const SMenuBackendInfo &CheckInfo) { - return str_comp_nocase(CheckInfo.m_pBackendName, "OpenGL") == 0 && CheckInfo.m_Major == 3 && CheckInfo.m_Minor == 0 && CheckInfo.m_Patch == 0; + return str_comp_nocase(CheckInfo.m_pBackendName, g_Config.ms_pGfxBackend) == 0 && CheckInfo.m_Major == g_Config.ms_GfxGLMajor && CheckInfo.m_Minor == g_Config.ms_GfxGLMinor && CheckInfo.m_Patch == g_Config.ms_GfxGLPatch; }; int OldSelectedBackend = -1;