From dab61709f8b75b1f57b2381c51f1fad1343496ed Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 8 Nov 2022 11:23:49 +0100 Subject: [PATCH] - added a compile option to fully disable the software renderer. This is mainly for new games which have been designed for hardware rendering. Note that this does not remove the software renderer's code - all it does is to disable the vid_rendermode CVAR by turning it into a static constant with the value 4. --- src/CMakeLists.txt | 5 +++++ src/common/menu/menudef.cpp | 6 ++++++ src/d_main.cpp | 2 ++ src/d_main.h | 4 ++++ wadsrc/static/menudef.txt | 5 ++++- wadsrc/static/menudef.zsimple | 5 ++++- 6 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4547d69b0..f1bced051 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,6 +27,11 @@ if( APPLE ) option( OSX_COCOA_BACKEND "Use native Cocoa backend instead of SDL" ON ) endif() +option( ZDOOM_ENABLE_SWR "Enable software renderer" ON ) +if( NOT ZDOOM_ENABLE_SWR ) + add_definitions( -DNO_SWRENDERER ) +endif() + target_architecture(TARGET_ARCHITECTURE) message(STATUS "Architecture is ${TARGET_ARCHITECTURE}") diff --git a/src/common/menu/menudef.cpp b/src/common/menu/menudef.cpp index c93c76bd7..0ef4e4fe1 100644 --- a/src/common/menu/menudef.cpp +++ b/src/common/menu/menudef.cpp @@ -250,6 +250,12 @@ static bool CheckSkipOptionBlock(FScanner &sc) filter = true; #endif } + else if (sc.Compare("SWRender")) + { +#ifndef NO_SWRENDERER + filter = true; +#endif + } } while (sc.CheckString(",")); sc.MustGetStringName(")"); diff --git a/src/d_main.cpp b/src/d_main.cpp index 8b3e5a728..c43ba2039 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -231,6 +231,7 @@ CUSTOM_CVAR(Float, i_timescale, 1.0f, CVAR_NOINITCALL | CVAR_VIRTUAL) // PUBLIC DATA DEFINITIONS ------------------------------------------------- +#ifndef NO_SWRENDERER CUSTOM_CVAR(Int, vid_rendermode, 4, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { if (self < 0 || self > 4) @@ -251,6 +252,7 @@ CUSTOM_CVAR(Int, vid_rendermode, 4, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOIN // No further checks needed. All this changes now is which scene drawer the render backend calls. } +#endif CUSTOM_CVAR (Int, fraglimit, 0, CVAR_SERVERINFO) { diff --git a/src/d_main.h b/src/d_main.h index 2698a738d..a6f76a8d8 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -149,7 +149,11 @@ public: }; +#ifndef NO_SWRENDERER EXTERN_CVAR(Int, vid_rendermode) +#else +constexpr int vid_rendermode = 4; +#endif inline bool V_IsHardwareRenderer() { diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 0ee511e59..c300e9b78 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -2271,7 +2271,10 @@ OptionMenu VideoModeMenu protected Option "$VIDMNU_PREFERBACKEND", "vid_preferbackend", "PreferBackend" StaticText " " - Option "$VIDMNU_RENDERMODE", "vid_rendermode", "RenderMode" + IfOption(SWRender) + { + Option "$VIDMNU_RENDERMODE", "vid_rendermode", "RenderMode" + } Option "$VIDMNU_FULLSCREEN", "vid_fullscreen", "YesNo" IfOption(Mac) diff --git a/wadsrc/static/menudef.zsimple b/wadsrc/static/menudef.zsimple index e0f6fc0b7..87cbb7ef4 100644 --- a/wadsrc/static/menudef.zsimple +++ b/wadsrc/static/menudef.zsimple @@ -47,7 +47,10 @@ OptionMenu VideoOptionsSimple protected Title "$DSPLYMNU_TITLE" Option "$VIDMNU_PREFERBACKEND", "vid_preferbackend", "PreferBackend" - Option "$VIDMNU_RENDERMODE", "vid_rendermode", "RenderMode" + IfOption(SWRender) + { + Option "$VIDMNU_RENDERMODE", "vid_rendermode", "RenderMode" + } Option "$VIDMNU_FULLSCREEN", "vid_fullscreen", "YesNo" IfOption(Mac) {