diff --git a/src/graphics/graphics_restrictions.cpp b/src/graphics/graphics_restrictions.cpp index 8e24c2da3..cf624eafd 100644 --- a/src/graphics/graphics_restrictions.cpp +++ b/src/graphics/graphics_restrictions.cpp @@ -63,6 +63,7 @@ namespace GraphicsRestrictions "FramebufferSRGBWorking", "FramebufferSRGBCapable", "GI", + "ForceLegacyDevice" }; } // namespace Private using namespace Private; diff --git a/src/graphics/graphics_restrictions.hpp b/src/graphics/graphics_restrictions.hpp index e21230af9..0f0038459 100644 --- a/src/graphics/graphics_restrictions.hpp +++ b/src/graphics/graphics_restrictions.hpp @@ -57,6 +57,7 @@ namespace GraphicsRestrictions GR_FRAMEBUFFER_SRGB_WORKING, GR_FRAMEBUFFER_SRGB_CAPABLE, GR_GI, + GR_FORCE_LEGACY_DEVICE, GR_COUNT /** MUST be last entry. */ } ; diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index 6fb6bfd5a..1bd49ab04 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -528,20 +528,40 @@ void IrrDriver::initDevice() } CVS->init(); + + bool recreate_device = false; + + // Some drivers are able to create OpenGL 3.1 context, but shader-based + // pipeline doesn't work for them. For example some radeon drivers + // support only GLSL 1.3 and it causes STK to crash. We should force to use + // fixed pipeline in this case. + if (GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_FORCE_LEGACY_DEVICE)) + { + Log::warn("irr_driver", "Driver doesn't support shader-based pipeline. " + "Re-creating device to workaround the issue."); + + params.ForceLegacyDevice = true; + recreate_device = true; + } // This is the ugly hack for intel driver on linux, which doesn't // use sRGB-capable visual, even if we request it. This causes // the screen to be darker than expected. It affects mesa 10.6 and newer. // Though we are able to force to use the proper format on mesa side by // setting WithAlphaChannel parameter. - if (!ProfileWorld::isNoGraphics() && CVS->needsSRGBCapableVisualWorkaround()) + else if (CVS->needsSRGBCapableVisualWorkaround()) { Log::warn("irr_driver", "Created visual is not sRGB-capable. " "Re-creating device to workaround the issue."); - m_device->closeDevice(); - m_device->drop(); params.WithAlphaChannel = true; + recreate_device = true; + } + + if (!ProfileWorld::isNoGraphics() && recreate_device) + { + m_device->closeDevice(); + m_device->drop(); m_device = createDeviceEx(params); @@ -549,6 +569,8 @@ void IrrDriver::initDevice() { Log::fatal("irr_driver", "Couldn't initialise irrlicht device. Quitting.\n"); } + + CVS->init(); } m_scene_manager = m_device->getSceneManager();