From 7f3722d90b1b422dbe87e2d4f08924b148bf97cc Mon Sep 17 00:00:00 2001 From: Benau Date: Fri, 12 Jan 2018 01:28:13 +0800 Subject: [PATCH] Make supports SP checking global --- src/graphics/central_settings.cpp | 18 ++++++++---------- src/graphics/central_settings.hpp | 3 ++- src/graphics/irr_driver.cpp | 4 +++- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/graphics/central_settings.cpp b/src/graphics/central_settings.cpp index c1785cdf6..e1bc50a35 100644 --- a/src/graphics/central_settings.cpp +++ b/src/graphics/central_settings.cpp @@ -24,6 +24,8 @@ #include "graphics/glwrap.hpp" #include "graphics/graphics_restrictions.hpp" +bool CentralVideoSettings::m_supports_sp = true; + CentralVideoSettings *CVS = new CentralVideoSettings(); void CentralVideoSettings::init() @@ -214,6 +216,12 @@ void CentralVideoSettings::init() // Compiler crashes with a big loop in RH or GI shaders m_need_rh_workaround = true; } + + // Check all extensions required by SP + m_supports_sp = isARBInstancedArraysUsable() && + isARBVertexType2101010RevUsable() && isARBSamplerObjectsUsable() && + isARBExplicitAttribLocationUsable(); + #else if (m_glsl == true) { @@ -489,16 +497,6 @@ bool CentralVideoSettings::isARBInstancedArraysUsable() const (m_gl_major_version > 3 || (m_gl_major_version == 3 && m_gl_minor_version >= 2)); } -bool CentralVideoSettings::supportsSP() const -{ -#ifdef USE_GLES2 - return true; -#else - return isARBInstancedArraysUsable() && isARBVertexType2101010RevUsable() && - isARBSamplerObjectsUsable() && isARBExplicitAttribLocationUsable(); -#endif -} - bool CentralVideoSettings::useArrayTextures() const { return false; diff --git a/src/graphics/central_settings.hpp b/src/graphics/central_settings.hpp index 2e6dd5a22..e17358845 100644 --- a/src/graphics/central_settings.hpp +++ b/src/graphics/central_settings.hpp @@ -58,6 +58,8 @@ private: bool m_need_vertex_id_workaround; bool m_GI_has_artifact; public: + static bool m_supports_sp; + void init(); bool isGLSL() const; unsigned getGLSLVersion() const; @@ -103,7 +105,6 @@ public: bool supportsComputeShadersFiltering() const; bool supportsHardwareSkinning() const; bool supportsTextureCompression() const; - bool supportsSP() const; bool supportsGLLayerInVertexShader() const; diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index c96831430..cd51eb9f9 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -463,6 +463,8 @@ void IrrDriver::initDevice() } #ifndef SERVER_ONLY + // Assume sp is supported + CentralVideoSettings::m_supports_sp = true; CVS->init(); bool recreate_device = false; @@ -473,7 +475,7 @@ void IrrDriver::initDevice() // fixed pipeline in this case. if (!ProfileWorld::isNoGraphics() && (GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_FORCE_LEGACY_DEVICE) || - !CVS->supportsSP())) + !CentralVideoSettings::m_supports_sp)) { Log::warn("irr_driver", "Driver doesn't support shader-based pipeline. " "Re-creating device to workaround the issue.");