From 52ab4b968f381588f2e43ebfa75d055840b91e4c Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Thu, 28 Feb 2019 21:19:09 -0800 Subject: [PATCH] Remove Quad-buffered from list of VR-modes if we know it won't work. --- src/d_main.cpp | 1 + src/menu/menu.h | 2 ++ src/menu/menudef.cpp | 28 +++++++++++++++++++++++ src/rendering/gl/renderer/gl_stereo3d.cpp | 3 +++ src/v_video.h | 1 - src/win32/gl_sysfb.cpp | 9 -------- src/win32/win32basevideo.cpp | 2 -- src/win32/win32glvideo.cpp | 9 +++++++- 8 files changed, 42 insertions(+), 13 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index f730493979..365b549388 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -2635,6 +2635,7 @@ void D_DoomMain (void) V_Init2(); UpdateJoystickMenu(NULL); + UpdateVRModes(); v = Args->CheckValue ("-loadgame"); if (v) diff --git a/src/menu/menu.h b/src/menu/menu.h index 43a96f8123..c2c54862a4 100644 --- a/src/menu/menu.h +++ b/src/menu/menu.h @@ -363,4 +363,6 @@ DMenuItemBase * CreateListMenuItemPatch(double x, double y, int height, int hotk DMenuItemBase * CreateListMenuItemText(double x, double y, int height, int hotkey, const char *text, FFont *font, PalEntry color1, PalEntry color2, FName command, int param); DMenuItemBase * CreateOptionMenuItemCommand(const char *label, FName cmd, bool centered = false); +void UpdateVRModes(bool considerQuadBuffered=true); + #endif diff --git a/src/menu/menudef.cpp b/src/menu/menudef.cpp index e3df4fbf07..80515d7790 100644 --- a/src/menu/menudef.cpp +++ b/src/menu/menudef.cpp @@ -1724,3 +1724,31 @@ fail: } } } + + +#ifdef _WIN32 +EXTERN_CVAR(Bool, vr_enable_quadbuffered) +#endif + +void UpdateVRModes(bool considerQuadBuffered) +{ + FOptionValues ** pVRModes = OptionValues.CheckKey("VRMode"); + if (pVRModes == nullptr) return; + + TArray & vals = (*pVRModes)->mValues; + TArray filteredValues; + int cnt = vals.Size(); + for (int i = 0; i < cnt; ++i) { + auto const & mode = vals[i]; + if (mode.Value == 7) { // Quad-buffered stereo +#ifdef _WIN32 + if (!vr_enable_quadbuffered) continue; +#else + continue +#endif + if (!considerQuadBuffered) continue; // Probably no compatible screen mode was found + } + filteredValues.Push(mode); + } + vals = filteredValues; +} diff --git a/src/rendering/gl/renderer/gl_stereo3d.cpp b/src/rendering/gl/renderer/gl_stereo3d.cpp index 6baaa801f6..35ea3c9140 100644 --- a/src/rendering/gl/renderer/gl_stereo3d.cpp +++ b/src/rendering/gl/renderer/gl_stereo3d.cpp @@ -34,6 +34,7 @@ #include "gl/system/gl_framebuffer.h" #include "hwrenderer/postprocessing/hw_presentshader.h" #include "hwrenderer/postprocessing/hw_present3dRowshader.h" +#include "menu/menu.h" EXTERN_CVAR(Int, vr_mode) EXTERN_CVAR(Float, vid_saturation) @@ -283,6 +284,8 @@ bool FGLRenderer::QuadStereoCheckInitialRenderContextState() // Now check whether this context supports hardware stereo glGetBooleanv(GL_STEREO, &supportsStereo); bQuadStereoSupported = supportsStereo && supportsBuffered; + if (! bQuadStereoSupported) + UpdateVRModes(false); } } return bQuadStereoSupported; diff --git a/src/v_video.h b/src/v_video.h index b4ecdeb9c3..b56c4e7276 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -361,7 +361,6 @@ public: float glslversion = 0; // This is here so that the differences between old OpenGL and new OpenGL/Vulkan can be handled by platform independent code. int instack[2] = { 0,0 }; // this is globally maintained state for portal recursion avoidance. int stencilValue = 0; // Global stencil test value - bool enable_quadbuffered = false; // Quad-buffered stereo available? unsigned int uniformblockalignment = 256; // Hardware dependent uniform buffer alignment. unsigned int maxuniformblock = 65536; const char *gl_vendorstring; // On OpenGL (not Vulkan) we have to account for some issues with Intel. diff --git a/src/win32/gl_sysfb.cpp b/src/win32/gl_sysfb.cpp index bc704bd69f..3ac1d7cf73 100644 --- a/src/win32/gl_sysfb.cpp +++ b/src/win32/gl_sysfb.cpp @@ -56,14 +56,6 @@ extern HWND Window; PFNWGLSWAPINTERVALEXTPROC myWglSwapIntervalExtProc; -// For broadest GL compatibility, require user to explicitly enable quad-buffered stereo mode. -// Setting vr_enable_quadbuffered_stereo does not automatically invoke quad-buffered stereo, -// but makes it possible for subsequent "vr_mode 7" to invoke quad-buffered stereo -CUSTOM_CVAR(Bool, vr_enable_quadbuffered, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) -{ - Printf("You must restart " GAMENAME " to switch quad stereo mode\n"); -} - //========================================================================== // // Windows framebuffer @@ -111,7 +103,6 @@ SystemGLFrameBuffer::SystemGLFrameBuffer(void *hMonitor, bool fullscreen) : Syst } } ReleaseDC(Window, hDC); - enable_quadbuffered = vr_enable_quadbuffered; } //========================================================================== diff --git a/src/win32/win32basevideo.cpp b/src/win32/win32basevideo.cpp index 090b0bb1d9..2d8ee7a2ff 100644 --- a/src/win32/win32basevideo.cpp +++ b/src/win32/win32basevideo.cpp @@ -55,8 +55,6 @@ CVAR(Int, vid_adapter, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) -EXTERN_CVAR(Bool, vr_enable_quadbuffered) - //========================================================================== // // diff --git a/src/win32/win32glvideo.cpp b/src/win32/win32glvideo.cpp index 9104e546b9..e283c700c1 100644 --- a/src/win32/win32glvideo.cpp +++ b/src/win32/win32glvideo.cpp @@ -54,7 +54,6 @@ #include "gl/system/gl_framebuffer.h" EXTERN_CVAR(Int, vid_adapter) -EXTERN_CVAR(Bool, vr_enable_quadbuffered) EXTERN_CVAR(Bool, vid_hdr) CUSTOM_CVAR(Bool, gl_debug, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) @@ -62,6 +61,14 @@ CUSTOM_CVAR(Bool, gl_debug, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINI Printf("This won't take effect until " GAMENAME " is restarted.\n"); } +// For broadest GL compatibility, require user to explicitly enable quad-buffered stereo mode. +// Setting vr_enable_quadbuffered_stereo does not automatically invoke quad-buffered stereo, +// but makes it possible for subsequent "vr_mode 7" to invoke quad-buffered stereo +CUSTOM_CVAR(Bool, vr_enable_quadbuffered, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + Printf("You must restart " GAMENAME " to switch quad stereo mode\n"); +} + extern bool vid_hdr_active; // these get used before GLEW is initialized so we have to use separate pointers with different names