Skip to content

Commit

Permalink
Bug 1657189 - Avoid GetFragDataLocation('gl_*') on Mesa. r=gfx-review…
Browse files Browse the repository at this point in the history
…ers,lsalzman

Differential Revision: https://phabricator.services.mozilla.com/D122406
  • Loading branch information
kdashg committed Aug 12, 2021
1 parent 65bc407 commit 1ab2048
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
7 changes: 7 additions & 0 deletions dom/canvas/WebGLContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
11 changes: 9 additions & 2 deletions gfx/gl/GLContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

////////////////
Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion gfx/gl/GLContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down Expand Up @@ -335,6 +335,7 @@ class GLContext : public GenericAtomicRefCounted, public SupportsWeakPtr {

GLVendor mVendor = GLVendor::Other;
GLRenderer mRenderer = GLRenderer::Other;
bool mIsMesa = false;

// -----------------------------------------------------------------------------
// Extensions management
Expand Down

0 comments on commit 1ab2048

Please sign in to comment.