Disable gamma correction on Windows + Intel HD 2/3000 / Intel HD Graphics

It's completely broken there. Closes #1592
This commit is contained in:
Alex Szpakowski
2020-12-24 20:31:33 -04:00
parent 90bd8f1811
commit fe23c16198
4 changed files with 23 additions and 13 deletions
-9
View File
@@ -39,11 +39,6 @@ static GLenum createFBO(GLuint &framebuffer, TextureType texType, PixelFormat fo
glGenFramebuffers(1, &framebuffer);
gl.bindFramebuffer(OpenGL::FRAMEBUFFER_ALL, framebuffer);
// Might work around an Intel driver bug: https://github.com/love2d/love/issues/1592
bool current_srgb = gl.isStateEnabled(OpenGL::ENABLE_FRAMEBUFFER_SRGB);
if (current_srgb && isPixelFormatDepthStencil(format))
gl.setEnableState(OpenGL::ENABLE_FRAMEBUFFER_SRGB, false);
if (texture != 0)
{
if (isPixelFormatDepthStencil(format) && (GLAD_ES_VERSION_3_0 || !GLAD_ES_VERSION_2_0))
@@ -110,10 +105,6 @@ static GLenum createFBO(GLuint &framebuffer, TextureType texType, PixelFormat fo
gl.bindFramebuffer(OpenGL::FRAMEBUFFER_ALL, current_fbo);
// Restore sRGB state if we turned it off above.
if (current_srgb && isPixelFormatDepthStencil(format))
gl.setEnableState(OpenGL::ENABLE_FRAMEBUFFER_SRGB, current_srgb);
return status;
}
+2 -2
View File
@@ -198,8 +198,8 @@ bool Graphics::setMode(int width, int height, int pixelwidth, int pixelheight, b
glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
// Set whether drawing converts input from linear -> sRGB colorspace.
if (GLAD_VERSION_3_0 || GLAD_ARB_framebuffer_sRGB || GLAD_EXT_framebuffer_sRGB
|| GLAD_ES_VERSION_3_0 || GLAD_EXT_sRGB)
if (!gl.bugs.brokenSRGB && (GLAD_VERSION_3_0 || GLAD_ARB_framebuffer_sRGB
|| GLAD_EXT_framebuffer_sRGB || GLAD_ES_VERSION_3_0 || GLAD_EXT_sRGB))
{
if (GLAD_VERSION_1_0 || GLAD_EXT_sRGB_write_control)
gl.setEnableState(OpenGL::ENABLE_FRAMEBUFFER_SRGB, isGammaCorrect());
+14 -2
View File
@@ -155,6 +155,16 @@ bool OpenGL::initContext()
if (strstr(device, "HD Graphics 4000") || strstr(device, "HD Graphics 2500"))
bugs.clientWaitSyncStalls = true;
}
if (getVendor() == VENDOR_INTEL)
{
const char *device = (const char *) glGetString(GL_RENDERER);
if (strstr(device, "HD Graphics 3000") || strstr(device, "HD Graphics 2000")
|| !strcmp(device, "Intel(R) HD Graphics") || !strcmp(device, "Intel(R) HD Graphics Family"))
{
bugs.brokenSRGB = true;
}
}
#endif
#ifdef LOVE_WINDOWS
@@ -215,8 +225,8 @@ void OpenGL::setupContext()
setEnableState(ENABLE_SCISSOR_TEST, state.enableState[ENABLE_SCISSOR_TEST]);
setEnableState(ENABLE_FACE_CULL, state.enableState[ENABLE_FACE_CULL]);
if (GLAD_VERSION_3_0 || GLAD_ARB_framebuffer_sRGB || GLAD_EXT_framebuffer_sRGB
|| GLAD_EXT_sRGB_write_control)
if (!bugs.brokenSRGB && (GLAD_VERSION_3_0 || GLAD_ARB_framebuffer_sRGB
|| GLAD_EXT_framebuffer_sRGB || GLAD_EXT_sRGB_write_control))
{
setEnableState(ENABLE_FRAMEBUFFER_SRGB, state.enableState[ENABLE_FRAMEBUFFER_SRGB]);
}
@@ -1717,6 +1727,8 @@ bool OpenGL::isPixelFormatSupported(PixelFormat pixelformat, bool rendertarget,
else
return true;
case PIXELFORMAT_sRGBA8:
if (gl.bugs.brokenSRGB)
return false;
if (rendertarget)
{
if (GLAD_VERSION_1_0)
+7
View File
@@ -177,6 +177,13 @@ public:
**/
bool brokenR8PixelFormat;
/**
* Intel HD Graphics drivers on Windows prior to the HD 2500/4000 have
* completely broken sRGB support.
* https://github.com/love2d/love/issues/1592
**/
bool brokenSRGB;
/**
* Other bugs which have workarounds that don't use conditional code at
* the moment: