diff --git a/dom/canvas/WebGLContext.cpp b/dom/canvas/WebGLContext.cpp index 5a36cba63f984..d6c4d910b20c2 100644 --- a/dom/canvas/WebGLContext.cpp +++ b/dom/canvas/WebGLContext.cpp @@ -2012,6 +2012,13 @@ GLint WebGLContext::GetFragDataLocation(const WebGLProgram& prog, } const auto mappedName = ret.str(); + if (gl->WorkAroundDriverBugs() && gl->IsMesa()) { + // Mesa incorrectly generates INVALID_OPERATION for gl_ prefixes here. + if (mappedName.find("gl_") == 0) { + return -1; + } + } + return gl->fGetFragDataLocation(prog.mGLName, mappedName.c_str()); } diff --git a/gfx/gl/GLContext.cpp b/gfx/gl/GLContext.cpp index b086b6c2bb502..b5000b5f0c560 100644 --- a/gfx/gl/GLContext.cpp +++ b/gfx/gl/GLContext.cpp @@ -666,11 +666,19 @@ bool GLContext::InitImpl() { } } + { + const auto versionStr = (const char*)fGetString(LOCAL_GL_VERSION); + if (strstr(versionStr, "Mesa")) { + mIsMesa = true; + } + } + if (ShouldSpew()) { printf_stderr("GL_VENDOR: %s\n", glVendorString); printf_stderr("mVendor: %s\n", vendorMatchStrings[size_t(mVendor)]); printf_stderr("GL_RENDERER: %s\n", glRendererString); printf_stderr("mRenderer: %s\n", rendererMatchStrings[size_t(mRenderer)]); + printf_stderr("mIsMesa: %i\n", int(mIsMesa)); } //////////////// @@ -732,8 +740,7 @@ bool GLContext::InitImpl() { MarkUnsupported(GLFeature::framebuffer_multisample); } - const auto versionStr = (const char*)fGetString(LOCAL_GL_VERSION); - if (strstr(versionStr, "Mesa")) { + if (IsMesa()) { // DrawElementsInstanced hangs the driver. MarkUnsupported(GLFeature::robust_buffer_access_behavior); } diff --git a/gfx/gl/GLContext.h b/gfx/gl/GLContext.h index d8da2ccc7ee3f..9f4a93205c3a1 100644 --- a/gfx/gl/GLContext.h +++ b/gfx/gl/GLContext.h @@ -280,8 +280,8 @@ class GLContext : public GenericAtomicRefCounted, public SupportsWeakPtr { } GLVendor Vendor() const { return mVendor; } - GLRenderer Renderer() const { return mRenderer; } + bool IsMesa() const { return mIsMesa; } bool IsContextLost() const { return mContextLost; } @@ -335,6 +335,7 @@ class GLContext : public GenericAtomicRefCounted, public SupportsWeakPtr { GLVendor mVendor = GLVendor::Other; GLRenderer mRenderer = GLRenderer::Other; + bool mIsMesa = false; // ----------------------------------------------------------------------------- // Extensions management