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; hasTextureCompression = false;
hasUBO = false; hasUBO = false;
hasGS = false; hasGS = false;
hasSRGBCapableVisual = false;
m_GI_has_artifact = false; m_GI_has_artifact = false;
m_need_rh_workaround = false; m_need_rh_workaround = false;
@ -179,6 +180,12 @@ void CentralVideoSettings::init()
// Bindless textures are all treated RGB even sRGB one // Bindless textures are all treated RGB even sRGB one
m_need_srgb_workaround = true; 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; return m_need_srgb_workaround;
} }
bool CentralVideoSettings::needsSRGBCapableVisualWorkaround() const
{
return !hasSRGBCapableVisual && GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_FRAMEBUFFER_SRGB_CAPABLE);
}
bool CentralVideoSettings::isARBGeometryShader4Usable() const bool CentralVideoSettings::isARBGeometryShader4Usable() const
{ {
return hasGS; return hasGS;

View File

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

View File

@ -511,14 +511,16 @@ void IrrDriver::initDevice()
} }
CVS->init(); CVS->init();
// This is the ugly hack for intel driver on linux, which doesn't // This is the ugly hack for intel driver on linux, which doesn't
// use sRGB-capable visual, even if we request it. This causes // use sRGB-capable visual, even if we request it. This causes
// the screen to be darker than expected. Setting WithAlphaChannel // the screen to be darker than expected. It affects mesa 10.6 and newer.
// to true forces using the proper format on mesa side. // Though we are able to force to use the proper format on mesa side by
if (!ProfileWorld::isNoGraphics() && GraphicsRestrictions::isDisabled( // setting WithAlphaChannel parameter.
GraphicsRestrictions::GR_FRAMEBUFFER_SRGB_CAPABLE)) 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->closeDevice();
m_device->drop(); m_device->drop();