Check if we really need to re-create the device by checking if framebuffer is sRGB or not.

This commit is contained in:
Deve 2015-12-11 18:53:48 +01:00
parent 6d757326d2
commit 7dd7f76e87
3 changed files with 21 additions and 5 deletions

View File

@ -46,6 +46,7 @@ void CentralVideoSettings::init()
hasTextureCompression = false;
hasUBO = false;
hasGS = false;
hasSRGBCapableVisual = false;
m_GI_has_artifact = false;
m_need_rh_workaround = false;
@ -179,6 +180,12 @@ void CentralVideoSettings::init()
// Bindless textures are all treated RGB even sRGB one
m_need_srgb_workaround = true;
}
// Check if visual is sRGB-capable
GLint param;
glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, GL_BACK_LEFT,
GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, &param);
hasSRGBCapableVisual = (param == GL_SRGB);
}
}
@ -207,6 +214,11 @@ bool CentralVideoSettings::needsRGBBindlessWorkaround() const
return m_need_srgb_workaround;
}
bool CentralVideoSettings::needsSRGBCapableVisualWorkaround() const
{
return !hasSRGBCapableVisual && GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_FRAMEBUFFER_SRGB_CAPABLE);
}
bool CentralVideoSettings::isARBGeometryShader4Usable() const
{
return hasGS;

View File

@ -40,6 +40,7 @@ private:
bool hasSSBO;
bool hasImageLoadStore;
bool hasMultiDrawIndirect;
bool hasSRGBCapableVisual;
bool m_need_rh_workaround;
bool m_need_srgb_workaround;
@ -52,6 +53,7 @@ public:
// Needs special handle ?
bool needRHWorkaround() const;
bool needsRGBBindlessWorkaround() const;
bool needsSRGBCapableVisualWorkaround() const;
// Extension is available and safe to use
bool isARBUniformBufferObjectUsable() const;

View File

@ -514,11 +514,13 @@ void IrrDriver::initDevice()
// 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. Setting WithAlphaChannel
// to true forces using the proper format on mesa side.
if (!ProfileWorld::isNoGraphics() && GraphicsRestrictions::isDisabled(
GraphicsRestrictions::GR_FRAMEBUFFER_SRGB_CAPABLE))
// 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())
{
Log::warn("irr_driver", "Created visual is not sRGB-capable. "
"Re-creating device to workaround the issue.");
m_device->closeDevice();
m_device->drop();