From c74356a1c008553e2dc1d5660902fdaf3d1d7a1c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 28 Jun 2017 17:57:04 +0200 Subject: [PATCH 1/2] - made OpenGL 3.3 a requirement for running the modern render path. Also force '-glversion 3' to use the modern render path, even though actual OpenGL 3.0 won't support it. This will exclude Intel HD3000 and many obsolete drivers for NVidia and ATI which should have been updated long ago. --- src/gl/system/gl_interface.cpp | 16 ++++------------ src/posix/cocoa/i_video.mm | 2 +- src/win32/win32gliface.cpp | 2 +- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index dcde3f006..85946d598 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -151,6 +151,7 @@ void gl_LoadExtensions() { double v1 = strtod(version, NULL); double v2 = strtod(glversion, NULL); + if (v1 >= 3.0 && v1 < 3.3) v1 = 3.3; // promote '3' to 3.3 to avoid falling back to the legacy path. if (v2 < v1) version = glversion; else Printf("Emulating OpenGL v %s\n", version); } @@ -204,8 +205,9 @@ void gl_LoadExtensions() gl.flags |= RFL_SAMPLER_OBJECTS; } - // The minimum requirement for the modern render path are GL 3.0 + uniform buffers. Also exclude the Linux Mesa driver at GL 3.0 because it errors out on shader compilation. - if (gl_version < 3.0f || (gl_version < 3.1f && (!CheckExtension("GL_ARB_uniform_buffer_object") || strstr(gl.vendorstring, "X.Org") != nullptr))) + // The minimum requirement for the modern render path is GL 3.3. + // Although some GL 3.1 or 3.2 solutions may theoretically work they are usually too broken or too slow. + if (gl_version < 3.3f) { gl.legacyMode = true; gl.lightmethod = LM_LEGACY; @@ -213,16 +215,6 @@ void gl_LoadExtensions() gl.glslversion = 0; gl.flags |= RFL_NO_CLIP_PLANES; } - else if (gl.glslversion < 1.4f && !CheckExtension("GL_ARB_uniform_buffer_object")) - { - // Some old ATI drivers report OpenGL 3.1 with GLSL version 1.3 and no support for uniform buffers. - // We have no choice but to force them down to OpenGL 2.x. - gl.legacyMode = true; - gl.lightmethod = LM_LEGACY; - gl.buffermethod = BM_LEGACY; - gl.glslversion = 0; - gl.flags |= RFL_NO_CLIP_PLANES; - } else { gl.legacyMode = false; diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index ed833e883..b51be142e 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -530,7 +530,7 @@ NSOpenGLPixelFormat* CreatePixelFormat(const OpenGLProfile profile) if (nullptr != glversion) { const double version = strtod(glversion, nullptr) + 0.01; - if (version < 3.2) + if (version < 3.0) { profile = NSOpenGLProfileVersionLegacy; } diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 614adaa2d..8071399db 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -877,7 +877,7 @@ bool Win32GLVideo::InitHardware (HWND Window, int multisample) int prof = WGL_CONTEXT_CORE_PROFILE_BIT_ARB; const char *version = Args->CheckValue("-glversion"); - if (version != nullptr && strcmp(version, "3.0") < 0) prof = WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; + if (version != nullptr && strtod(version, nullptr) < 3.0) prof = WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; for (; prof <= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; prof++) { From 0cd575363ff51b4850477655ec13597eea9fae7d Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 28 Jun 2017 19:55:11 +0200 Subject: [PATCH 2/2] - Add r_sprite_distance_cull that per default culls all things further than 5000 units away --- src/swrenderer/scene/r_opaque_pass.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/swrenderer/scene/r_opaque_pass.cpp b/src/swrenderer/scene/r_opaque_pass.cpp index 7d6d6b461..bebb9580f 100644 --- a/src/swrenderer/scene/r_opaque_pass.cpp +++ b/src/swrenderer/scene/r_opaque_pass.cpp @@ -72,6 +72,20 @@ EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); EXTERN_CVAR(Bool, r_drawvoxels); +namespace { double sprite_distance_cull = 1e16; } + +CUSTOM_CVAR(Float, r_sprite_distance_cull, 5000.0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +{ + if (r_sprite_distance_cull > 0.0) + { + sprite_distance_cull = r_sprite_distance_cull * r_sprite_distance_cull; + } + else + { + sprite_distance_cull = 1e16; + } +} + namespace swrenderer { RenderOpaquePass::RenderOpaquePass(RenderThread *thread) : renderline(thread) @@ -936,6 +950,10 @@ namespace swrenderer if (!renderportal->CurrentPortalInSkybox && renderportal->CurrentPortal && !!P_PointOnLineSidePrecise(thing->Pos(), renderportal->CurrentPortal->dst)) return false; + double distanceSquared = (thing->Pos() - Thread->Viewport->viewpoint.Pos).LengthSquared(); + if (distanceSquared > sprite_distance_cull) + return false; + return true; }