Bug 1526027 - Remove webgl.bypass-shader-validation. r=lsalzman
authorJeff Gilbert <jgilbert@mozilla.com>
Fri, 17 May 2019 02:36:57 +0000
changeset 533100 ba078373f2c242bdada0f3cd73a2b28b03029480
parent 533099 7b72fa29c64be23ef4ac7f2373e5622adb48b337
child 533101 41abcc2640371974e4067240da2885ddcf0a805c
push id11276
push userrgurzau@mozilla.com
push dateMon, 20 May 2019 13:11:24 +0000
treeherdermozilla-beta@847755a7c325 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslsalzman
bugs1526027
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1526027 - Remove webgl.bypass-shader-validation. r=lsalzman Also remove extra plumbing from WebGLShaderValidator, moved directly into WebGLShader. Differential Revision: https://phabricator.services.mozilla.com/D31567
dom/canvas/WebGLContext.cpp
dom/canvas/WebGLContext.h
dom/canvas/WebGLContextValidate.cpp
dom/canvas/WebGLProgram.cpp
dom/canvas/WebGLProgram.h
dom/canvas/WebGLShader.cpp
dom/canvas/WebGLShader.h
dom/canvas/WebGLShaderValidator.cpp
dom/canvas/WebGLShaderValidator.h
gfx/thebes/gfxPrefs.h
modules/libpref/init/all.js
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -116,17 +116,16 @@ bool WebGLContextOptions::operator==(con
 WebGLContext::WebGLContext()
     : gl(mGL_OnlyClearInDestroyResourcesAndContext)  // const reference
       ,
       mMaxPerfWarnings(gfxPrefs::WebGLMaxPerfWarnings()),
       mNumPerfWarnings(0),
       mMaxAcceptableFBStatusInvals(
           gfxPrefs::WebGLMaxAcceptableFBStatusInvals()),
       mDataAllocGLCallCount(0),
-      mBypassShaderValidation(false),
       mEmptyTFO(0),
       mContextLossHandler(this),
       mNeedsFakeNoAlpha(false),
       mNeedsFakeNoDepth(false),
       mNeedsFakeNoStencil(false),
       mAllowFBInvalidation(gfxPrefs::WebGLFBInvalidation()),
       mMsaaSamples((uint8_t)gfxPrefs::WebGLMsaaSamples()) {
   mGeneration = 0;
--- a/dom/canvas/WebGLContext.h
+++ b/dom/canvas/WebGLContext.h
@@ -1486,18 +1486,16 @@ class WebGLContext : public nsICanvasRen
   void DeleteWebGLObjectsArray(nsTArray<WebGLObjectType>& array);
 
   GLuint mActiveTexture = 0;
   GLenum mDefaultFB_DrawBuffer0 = 0;
   GLenum mDefaultFB_ReadBuffer = 0;
 
   mutable GLenum mWebGLError;
 
-  bool mBypassShaderValidation;
-
   webgl::ShaderValidator* CreateShaderValidator(GLenum shaderType) const;
 
   // some GL constants
   uint32_t mGLMaxTextureUnits = 0;
 
   uint32_t mGLMaxVertexAttribs = 0;
   uint32_t mGLMaxFragmentUniformVectors = 0;
   uint32_t mGLMaxVertexUniformVectors = 0;
--- a/dom/canvas/WebGLContextValidate.cpp
+++ b/dom/canvas/WebGLContextValidate.cpp
@@ -577,19 +577,16 @@ bool WebGLContext::InitAndValidateGL(Fai
                          LOCAL_GL_LOWER_LEFT);
   }
 #endif
 
   if (gl->IsSupported(gl::GLFeature::seamless_cube_map_opt_in)) {
     gl->fEnable(LOCAL_GL_TEXTURE_CUBE_MAP_SEAMLESS);
   }
 
-  // Check the shader validator pref
-  mBypassShaderValidation = gfxPrefs::WebGLBypassShaderValidator();
-
   // initialize shader translator
   if (!sh::Initialize()) {
     *out_failReason = {"FEATURE_FAILURE_WEBGL_GLSL",
                        "GLSL translator initialization failed!"};
     return false;
   }
 
   // Mesa can only be detected with the GL_VERSION string, of the form
--- a/dom/canvas/WebGLProgram.cpp
+++ b/dom/canvas/WebGLProgram.cpp
@@ -471,17 +471,17 @@ static RefPtr<const webgl::LinkedProgram
   }
 
   // Frag outputs
 
   {
     const auto& fragShader = prog->FragShader();
     MOZ_RELEASE_ASSERT(fragShader);
     MOZ_RELEASE_ASSERT(fragShader->Validator());
-    const auto& handle = fragShader->Validator()->Handle();
+    const auto& handle = fragShader->Validator()->mHandle;
     const auto version = sh::GetShaderVersion(handle);
 
     const auto fnAddInfo = [&](const webgl::FragOutputInfo& x) {
       info->fragOutputs.insert({x.loc, x});
     };
 
     if (version == 300) {
       const auto& fragOutputs = sh::GetOutputVariables(handle);
@@ -738,23 +738,24 @@ void WebGLProgram::BindAttribLocation(GL
 
   if (StringBeginsWith(name, NS_LITERAL_STRING("gl_"))) {
     mContext->ErrorInvalidOperation(
         "Can't set the location of a"
         " name that starts with 'gl_'.");
     return;
   }
 
-  NS_LossyConvertUTF16toASCII asciiName(name);
-
-  auto res = mNextLink_BoundAttribLocs.insert({asciiName, loc});
+  const NS_LossyConvertUTF16toASCII asciiName(name);
+  const std::string asciiNameStr(asciiName.BeginReading());
 
-  const bool wasInserted = res.second;
+  auto res = mNextLink_BoundAttribLocs.insert({asciiNameStr, loc});
+
+  const auto& wasInserted = res.second;
   if (!wasInserted) {
-    auto itr = res.first;
+    const auto& itr = res.first;
     itr->second = loc;
   }
 }
 
 void WebGLProgram::DetachShader(const WebGLShader* shader) {
   MOZ_ASSERT(shader);
 
   WebGLRefPtr<WebGLShader>* shaderSlot;
--- a/dom/canvas/WebGLProgram.h
+++ b/dom/canvas/WebGLProgram.h
@@ -224,17 +224,17 @@ class WebGLProgram final : public nsWrap
  public:
   const GLuint mGLName;
 
  private:
   WebGLRefPtr<WebGLShader> mVertShader;
   WebGLRefPtr<WebGLShader> mFragShader;
   size_t mNumActiveTFOs;
 
-  std::map<nsCString, GLuint> mNextLink_BoundAttribLocs;
+  std::map<std::string, GLuint> mNextLink_BoundAttribLocs;
 
   std::vector<nsString> mNextLink_TransformFeedbackVaryings;
   GLenum mNextLink_TransformFeedbackBufferMode;
 
   nsCString mLinkLog;
   RefPtr<const webgl::LinkedProgramInfo> mMostRecentLinkInfo;
 };
 
--- a/dom/canvas/WebGLShader.cpp
+++ b/dom/canvas/WebGLShader.cpp
@@ -40,96 +40,37 @@ static void PrintLongString(const char* 
 
 // On success, writes to out_validator and out_translatedSource.
 // On failure, writes to out_translationLog.
 static bool Translate(const nsACString& source,
                       webgl::ShaderValidator* validator,
                       nsACString* const out_translationLog,
                       nsACString* const out_translatedSource) {
   if (!validator->ValidateAndTranslate(source.BeginReading())) {
-    validator->GetInfoLog(out_translationLog);
+    const std::string& log = sh::GetInfoLog(validator->mHandle);
+    out_translationLog->Assign(log.data(), log.length());
     return false;
   }
 
   // Success
-  validator->GetOutput(out_translatedSource);
+  const std::string& output = sh::GetObjectCode(validator->mHandle);
+  out_translatedSource->Assign(output.data(), output.length());
+
   return true;
 }
 
 template <size_t N>
 static bool SubstringStartsWith(const std::string& testStr, size_t offset,
                                 const char (&refStr)[N]) {
   for (size_t i = 0; i < N - 1; i++) {
     if (testStr[offset + i] != refStr[i]) return false;
   }
   return true;
 }
 
-/* On success, writes to out_translatedSource.
- * On failure, writes to out_translationLog.
- *
- * Requirements:
- *   #version is either omitted, `#version 100`, or `version 300 es`.
- */
-static bool TranslateWithoutValidation(const nsACString& sourceNS,
-                                       bool isWebGL2,
-                                       nsACString* const out_translationLog,
-                                       nsACString* const out_translatedSource) {
-  std::string source = sourceNS.BeginReading();
-
-  size_t versionStrStart = source.find("#version");
-  size_t versionStrLen;
-  uint32_t glesslVersion;
-
-  if (versionStrStart != std::string::npos) {
-    static const char versionStr100[] = "#version 100\n";
-    static const char versionStr300es[] = "#version 300 es\n";
-
-    if (isWebGL2 &&
-        SubstringStartsWith(source, versionStrStart, versionStr300es)) {
-      glesslVersion = 300;
-      versionStrLen = strlen(versionStr300es);
-
-    } else if (SubstringStartsWith(source, versionStrStart, versionStr100)) {
-      glesslVersion = 100;
-      versionStrLen = strlen(versionStr100);
-
-    } else {
-      nsPrintfCString error("#version, if declared, must be %s.",
-                            isWebGL2 ? "`100` or `300 es`" : "`100`");
-      *out_translationLog = error;
-      return false;
-    }
-  } else {
-    versionStrStart = 0;
-    versionStrLen = 0;
-    glesslVersion = 100;
-  }
-
-  std::string reversionedSource = source;
-  reversionedSource.erase(versionStrStart, versionStrLen);
-
-  switch (glesslVersion) {
-    case 100:
-      /* According to ARB_ES2_compatibility extension glsl
-       * should accept #version 100 for ES 2 shaders. */
-      reversionedSource.insert(versionStrStart, "#version 100\n");
-      break;
-    case 300:
-      reversionedSource.insert(versionStrStart, "#version 330\n");
-      break;
-    default:
-      MOZ_CRASH("GFX: Bad `glesslVersion`.");
-  }
-
-  out_translatedSource->Assign(reversionedSource.c_str(),
-                               reversionedSource.length());
-  return true;
-}
-
 static void GetCompilationStatusAndLog(gl::GLContext* gl, GLuint shader,
                                        bool* const out_success,
                                        nsACString* const out_log) {
   GLint compileStatus = LOCAL_GL_FALSE;
   gl->fGetShaderiv(shader, LOCAL_GL_COMPILE_STATUS, &compileStatus);
 
   // It's simpler if we always get the log.
   GLint lenWithNull = 0;
@@ -180,31 +121,26 @@ void WebGLShader::ShaderSource(const nsA
 void WebGLShader::CompileShader() {
   mValidator = nullptr;
   mTranslationSuccessful = false;
   mCompilationSuccessful = false;
 
   gl::GLContext* gl = mContext->gl;
 
   mValidator.reset(mContext->CreateShaderValidator(mType));
+  MOZ_ASSERT(mValidator);
 
   static const bool kDumpShaders = PR_GetEnv("MOZ_WEBGL_DUMP_SHADERS");
   if (MOZ_UNLIKELY(kDumpShaders)) {
     printf_stderr("==== begin MOZ_WEBGL_DUMP_SHADERS ====\n");
     PrintLongString(mCleanSource.BeginReading(), mCleanSource.Length());
   }
 
-  bool success;
-  if (mValidator) {
-    success = Translate(mCleanSource, mValidator.get(), &mValidationLog,
+  const bool success = Translate(mCleanSource, mValidator.get(), &mValidationLog,
                         &mTranslatedSource);
-  } else {
-    success = TranslateWithoutValidation(mCleanSource, mContext->IsWebGL2(),
-                                         &mValidationLog, &mTranslatedSource);
-  }
 
   if (MOZ_UNLIKELY(kDumpShaders)) {
     printf_stderr("\n==== \\/ \\/ \\/ ====\n");
     if (success) {
       PrintLongString(mTranslatedSource.BeginReading(),
                       mTranslatedSource.Length());
     } else {
       printf_stderr("Validation failed:\n%s", mValidationLog.BeginReading());
@@ -257,119 +193,132 @@ void WebGLShader::GetShaderTranslatedSou
   out->SetIsVoid(false);
   CopyASCIItoUTF16(mTranslatedSource, *out);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
 bool WebGLShader::CanLinkTo(const WebGLShader* prev,
                             nsCString* const out_log) const {
-  if (!mValidator) return true;
-
   return mValidator->CanLinkTo(prev->mValidator.get(), out_log);
 }
 
 size_t WebGLShader::CalcNumSamplerUniforms() const {
-  if (mValidator) return mValidator->CalcNumSamplerUniforms();
-
-  // TODO
-  return 0;
+  const auto& uniforms = *sh::GetUniforms(mValidator->mHandle);
+  size_t accum = 0;
+  for (const auto& cur : uniforms) {
+    const auto& type = cur.type;
+    if (type == LOCAL_GL_SAMPLER_2D || type == LOCAL_GL_SAMPLER_CUBE) {
+      accum += cur.getArraySizeProduct();
+    }
+  }
+  return accum;
 }
 
 size_t WebGLShader::NumAttributes() const {
-  if (mValidator) return mValidator->NumAttributes();
-
-  // TODO
-  return 0;
+  return sh::GetAttributes(mValidator->mHandle)->size();
 }
 
-void WebGLShader::BindAttribLocation(GLuint prog, const nsCString& userName,
+void WebGLShader::BindAttribLocation(GLuint prog, const std::string& userName,
                                      GLuint index) const {
-  std::string userNameStr(userName.BeginReading());
-
-  const std::string* mappedNameStr = &userNameStr;
-  if (mValidator)
-    mValidator->FindAttribMappedNameByUserName(userNameStr, &mappedNameStr);
-
-  mContext->gl->fBindAttribLocation(prog, index, mappedNameStr->c_str());
+  const auto& attribs = *sh::GetAttributes(mValidator->mHandle);
+  for (const auto& attrib : attribs) {
+    if (attrib.name == userName) {
+      mContext->gl->fBindAttribLocation(prog, index, attrib.mappedName.c_str());
+      return;
+    }
+  }
 }
 
 bool WebGLShader::FindAttribUserNameByMappedName(
     const nsACString& mappedName, nsCString* const out_userName) const {
-  if (!mValidator) return false;
+  const std::string mappedNameStr(mappedName.BeginReading());
 
-  const std::string mappedNameStr(mappedName.BeginReading());
-  const std::string* userNameStr;
-  if (!mValidator->FindAttribUserNameByMappedName(mappedNameStr, &userNameStr))
-    return false;
-
-  *out_userName = userNameStr->c_str();
-  return true;
+  const auto& attribs = *sh::GetAttributes(mValidator->mHandle);
+  for (const auto& cur : attribs) {
+    if (cur.mappedName == mappedNameStr) {
+      *out_userName = cur.name.c_str();
+      return true;
+    }
+  }
+  return false;
 }
 
 bool WebGLShader::FindVaryingByMappedName(const nsACString& mappedName,
                                           nsCString* const out_userName,
                                           bool* const out_isArray) const {
-  if (!mValidator) return false;
+  const std::string mappedNameStr(mappedName.BeginReading());
 
-  const std::string mappedNameStr(mappedName.BeginReading());
-  std::string userNameStr;
-  if (!mValidator->FindVaryingByMappedName(mappedNameStr, &userNameStr,
-                                           out_isArray))
-    return false;
+  const auto& varyings = *sh::GetVaryings(mValidator->mHandle);
+  for (const auto& cur : varyings) {
+    const sh::ShaderVariable* found;
+    std::string userName;
+    if (!cur.findInfoByMappedName(mappedNameStr, &found, &userName)) continue;
 
-  *out_userName = userNameStr.c_str();
-  return true;
+    *out_userName = userName.c_str();
+    *out_isArray = found->isArray();
+    return true;
+  }
+
+  return false;
 }
 
 bool WebGLShader::FindUniformByMappedName(const nsACString& mappedName,
                                           nsCString* const out_userName,
                                           bool* const out_isArray) const {
-  if (!mValidator) return false;
-
   const std::string mappedNameStr(mappedName.BeginReading(),
                                   mappedName.Length());
   std::string userNameStr;
   if (!mValidator->FindUniformByMappedName(mappedNameStr, &userNameStr,
                                            out_isArray))
     return false;
 
   *out_userName = userNameStr.c_str();
   return true;
 }
 
 bool WebGLShader::UnmapUniformBlockName(
     const nsACString& baseMappedName, nsCString* const out_baseUserName) const {
-  if (!mValidator) {
-    *out_baseUserName = baseMappedName;
-    return true;
+  const auto& interfaces = *sh::GetInterfaceBlocks(mValidator->mHandle);
+  for (const auto& interface : interfaces) {
+    const nsDependentCString interfaceMappedName(interface.mappedName.data(),
+                                                 interface.mappedName.size());
+    if (baseMappedName == interfaceMappedName) {
+      *out_baseUserName = interface.name.data();
+      return true;
+    }
   }
 
-  return mValidator->UnmapUniformBlockName(baseMappedName, out_baseUserName);
+  return false;
 }
 
 void WebGLShader::MapTransformFeedbackVaryings(
     const std::vector<nsString>& varyings,
     std::vector<std::string>* out_mappedVaryings) const {
   MOZ_ASSERT(mType == LOCAL_GL_VERTEX_SHADER);
   MOZ_ASSERT(out_mappedVaryings);
 
   out_mappedVaryings->clear();
   out_mappedVaryings->reserve(varyings.size());
 
+  const auto& shaderVaryings = *sh::GetVaryings(mValidator->mHandle);
+
   for (const auto& wideUserName : varyings) {
     const NS_LossyConvertUTF16toASCII mozUserName(
         wideUserName);  // Don't validate here.
     const std::string userName(mozUserName.BeginReading(),
                                mozUserName.Length());
-    const std::string* pMappedName = &userName;
-    if (mValidator) {
-      mValidator->FindVaryingMappedNameByUserName(userName, &pMappedName);
+    const auto* mappedName = &userName;
+    for (const auto& shaderVarying : shaderVaryings) {
+      if (shaderVarying.name == userName) {
+        mappedName = &shaderVarying.mappedName;
+        break;
+      }
     }
-    out_mappedVaryings->push_back(*pMappedName);
+    out_mappedVaryings->push_back(*mappedName);
   }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // Boilerplate
 
 JSObject* WebGLShader::WrapObject(JSContext* js,
                                   JS::Handle<JSObject*> givenProto) {
--- a/dom/canvas/WebGLShader.h
+++ b/dom/canvas/WebGLShader.h
@@ -62,17 +62,17 @@ class WebGLShader final : public nsWrapp
 
   bool IsCompiled() const {
     return mTranslationSuccessful && mCompilationSuccessful;
   }
   const auto* Validator() const { return mValidator.get(); }
   const auto& TranslatedSource() const { return mTranslatedSource; }
 
  private:
-  void BindAttribLocation(GLuint prog, const nsCString& userName,
+  void BindAttribLocation(GLuint prog, const std::string& userName,
                           GLuint index) const;
   void MapTransformFeedbackVaryings(
       const std::vector<nsString>& varyings,
       std::vector<std::string>* out_mappedVaryings) const;
 
  public:
   // Other funcs
   size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
--- a/dom/canvas/WebGLShaderValidator.cpp
+++ b/dom/canvas/WebGLShaderValidator.cpp
@@ -136,18 +136,16 @@ static ShShaderOutput ShaderOutput(gl::G
     }
   }
 
   return SH_GLSL_COMPATIBILITY_OUTPUT;
 }
 
 webgl::ShaderValidator* WebGLContext::CreateShaderValidator(
     GLenum shaderType) const {
-  if (mBypassShaderValidation) return nullptr;
-
   const auto spec = (IsWebGL2() ? SH_WEBGL2_SPEC : SH_WEBGL_SPEC);
   const auto outputLanguage = ShaderOutput(gl);
 
   ShBuiltInResources resources;
   memset(&resources, 0, sizeof(resources));
   sh::InitBuiltInResources(&resources);
 
   resources.HashFunction = webgl::IdentifierHashFunc;
@@ -227,30 +225,16 @@ ShaderValidator::~ShaderValidator() { sh
 bool ShaderValidator::ValidateAndTranslate(const char* source) {
   MOZ_ASSERT(!mHasRun);
   mHasRun = true;
 
   const char* const parts[] = {source};
   return sh::Compile(mHandle, parts, ArrayLength(parts), mCompileOptions);
 }
 
-void ShaderValidator::GetInfoLog(nsACString* out) const {
-  MOZ_ASSERT(mHasRun);
-
-  const std::string& log = sh::GetInfoLog(mHandle);
-  out->Assign(log.data(), log.length());
-}
-
-void ShaderValidator::GetOutput(nsACString* out) const {
-  MOZ_ASSERT(mHasRun);
-
-  const std::string& output = sh::GetObjectCode(mHandle);
-  out->Assign(output.data(), output.length());
-}
-
 template <size_t N>
 static bool StartsWith(const std::string& haystack, const char (&needle)[N]) {
   return haystack.compare(0, N - 1, needle) == 0;
 }
 
 bool ShaderValidator::CanLinkTo(const ShaderValidator* prev,
                                 nsCString* const out_log) const {
   if (!prev) {
@@ -433,93 +417,16 @@ bool ShaderValidator::CanLinkTo(const Sh
           " Specification 1.0.17, p39)";
       return false;
     }
   }
 
   return true;
 }
 
-size_t ShaderValidator::CalcNumSamplerUniforms() const {
-  size_t accum = 0;
-
-  const std::vector<sh::Uniform>& uniforms = *sh::GetUniforms(mHandle);
-
-  for (auto itr = uniforms.begin(); itr != uniforms.end(); ++itr) {
-    GLenum type = itr->type;
-    if (type == LOCAL_GL_SAMPLER_2D || type == LOCAL_GL_SAMPLER_CUBE) {
-      accum += itr->getArraySizeProduct();
-    }
-  }
-
-  return accum;
-}
-
-size_t ShaderValidator::NumAttributes() const {
-  return sh::GetAttributes(mHandle)->size();
-}
-
-// Attribs cannot be structs or arrays, and neither can vertex inputs in ES3.
-// Therefore, attrib names are always simple.
-bool ShaderValidator::FindAttribUserNameByMappedName(
-    const std::string& mappedName,
-    const std::string** const out_userName) const {
-  const std::vector<sh::Attribute>& attribs = *sh::GetAttributes(mHandle);
-  for (auto itr = attribs.begin(); itr != attribs.end(); ++itr) {
-    if (itr->mappedName == mappedName) {
-      *out_userName = &(itr->name);
-      return true;
-    }
-  }
-
-  return false;
-}
-
-bool ShaderValidator::FindAttribMappedNameByUserName(
-    const std::string& userName,
-    const std::string** const out_mappedName) const {
-  const std::vector<sh::Attribute>& attribs = *sh::GetAttributes(mHandle);
-  for (auto itr = attribs.begin(); itr != attribs.end(); ++itr) {
-    if (itr->name == userName) {
-      *out_mappedName = &(itr->mappedName);
-      return true;
-    }
-  }
-
-  return false;
-}
-
-bool ShaderValidator::FindVaryingByMappedName(const std::string& mappedName,
-                                              std::string* const out_userName,
-                                              bool* const out_isArray) const {
-  const std::vector<sh::Varying>& varyings = *sh::GetVaryings(mHandle);
-  for (auto itr = varyings.begin(); itr != varyings.end(); ++itr) {
-    const sh::ShaderVariable* found;
-    if (!itr->findInfoByMappedName(mappedName, &found, out_userName)) continue;
-
-    *out_isArray = found->isArray();
-    return true;
-  }
-
-  return false;
-}
-
-bool ShaderValidator::FindVaryingMappedNameByUserName(
-    const std::string& userName,
-    const std::string** const out_mappedName) const {
-  const std::vector<sh::Varying>& attribs = *sh::GetVaryings(mHandle);
-  for (auto itr = attribs.begin(); itr != attribs.end(); ++itr) {
-    if (itr->name == userName) {
-      *out_mappedName = &(itr->mappedName);
-      return true;
-    }
-  }
-
-  return false;
-}
 // This must handle names like "foo.bar[0]".
 bool ShaderValidator::FindUniformByMappedName(const std::string& mappedName,
                                               std::string* const out_userName,
                                               bool* const out_isArray) const {
   const std::vector<sh::Uniform>& uniforms = *sh::GetUniforms(mHandle);
   for (auto itr = uniforms.begin(); itr != uniforms.end(); ++itr) {
     const sh::ShaderVariable* found;
     if (!itr->findInfoByMappedName(mappedName, &found, out_userName)) continue;
@@ -566,26 +473,10 @@ bool ShaderValidator::FindUniformByMappe
       *out_isArray = found->isArray();
       return true;
     }
   }
 
   return false;
 }
 
-bool ShaderValidator::UnmapUniformBlockName(
-    const nsACString& baseMappedName, nsCString* const out_baseUserName) const {
-  const std::vector<sh::InterfaceBlock>& interfaces =
-      *sh::GetInterfaceBlocks(mHandle);
-  for (const auto& interface : interfaces) {
-    const nsDependentCString interfaceMappedName(interface.mappedName.data(),
-                                                 interface.mappedName.size());
-    if (baseMappedName == interfaceMappedName) {
-      *out_baseUserName = interface.name.data();
-      return true;
-    }
-  }
-
-  return false;
-}
-
 }  // namespace webgl
 }  // namespace mozilla
--- a/dom/canvas/WebGLShaderValidator.h
+++ b/dom/canvas/WebGLShaderValidator.h
@@ -11,17 +11,19 @@
 #include "GLDefs.h"
 #include "GLSLANG/ShaderLang.h"
 #include "nsString.h"
 
 namespace mozilla {
 namespace webgl {
 
 class ShaderValidator final {
+public:
   const ShHandle mHandle;
+private:
   const ShCompileOptions mCompileOptions;
   const int mMaxVaryingVectors;
   bool mHasRun;
 
  public:
   static ShaderValidator* Create(GLenum shaderType, ShShaderSpec spec,
                                  ShShaderOutput outputLanguage,
                                  const ShBuiltInResources& resources,
@@ -34,43 +36,21 @@ class ShaderValidator final {
         mCompileOptions(compileOptions),
         mMaxVaryingVectors(maxVaryingVectors),
         mHasRun(false) {}
 
  public:
   ~ShaderValidator();
 
   bool ValidateAndTranslate(const char* source);
-  void GetInfoLog(nsACString* out) const;
-  void GetOutput(nsACString* out) const;
   bool CanLinkTo(const ShaderValidator* prev, nsCString* const out_log) const;
-  size_t CalcNumSamplerUniforms() const;
-  size_t NumAttributes() const;
-  const auto& Handle() const { return mHandle; }
-
-  bool FindAttribUserNameByMappedName(
-      const std::string& mappedName,
-      const std::string** const out_userName) const;
 
-  bool FindAttribMappedNameByUserName(
-      const std::string& userName,
-      const std::string** const out_mappedName) const;
-
-  bool FindVaryingMappedNameByUserName(
-      const std::string& userName,
-      const std::string** const out_mappedName) const;
-
-  bool FindVaryingByMappedName(const std::string& mappedName,
-                               std::string* const out_userName,
-                               bool* const out_isArray) const;
   bool FindUniformByMappedName(const std::string& mappedName,
                                std::string* const out_userName,
                                bool* const out_isArray) const;
-  bool UnmapUniformBlockName(const nsACString& baseMappedName,
-                             nsCString* const out_baseUserName) const;
 
   bool ValidateTransformFeedback(
       const std::vector<nsString>& userNames, uint32_t maxComponents,
       nsCString* const out_errorText,
       std::vector<std::string>* const out_mappedNames);
 };
 
 }  // namespace webgl
--- a/gfx/thebes/gfxPrefs.h
+++ b/gfx/thebes/gfxPrefs.h
@@ -778,17 +778,16 @@ class gfxPrefs final {
 
   // WebGL (for pref access from Worker threads)
   DECL_GFX_PREF(Live, "webgl.1.allow-core-profiles",           WebGL1AllowCoreProfile, bool, false);
 
   DECL_GFX_PREF(Live, "webgl.all-angle-options",               WebGLAllANGLEOptions, bool, false);
   DECL_GFX_PREF(Live, "webgl.angle.force-d3d11",               WebGLANGLEForceD3D11, bool, false);
   DECL_GFX_PREF(Live, "webgl.angle.try-d3d11",                 WebGLANGLETryD3D11, bool, false);
   DECL_GFX_PREF(Live, "webgl.angle.force-warp",                WebGLANGLEForceWARP, bool, false);
-  DECL_GFX_PREF(Live, "webgl.bypass-shader-validation",        WebGLBypassShaderValidator, bool, true);
   DECL_GFX_PREF(Live, "webgl.can-lose-context-in-foreground",  WebGLCanLoseContextInForeground, bool, true);
   DECL_GFX_PREF(Live, "webgl.default-low-power",               WebGLDefaultLowPower, bool, false);
   DECL_GFX_PREF(Live, "webgl.default-no-alpha",                WebGLDefaultNoAlpha, bool, false);
   DECL_GFX_PREF(Live, "webgl.disable-angle",                   WebGLDisableANGLE, bool, false);
   DECL_GFX_PREF(Live, "webgl.disable-wgl",                     WebGLDisableWGL, bool, false);
   DECL_GFX_PREF(Live, "webgl.disable-extensions",              WebGLDisableExtensions, bool, false);
   DECL_GFX_PREF(Live, "webgl.dxgl.enabled",                    WebGLDXGLEnabled, bool, false);
   DECL_GFX_PREF(Live, "webgl.dxgl.needs-finish",               WebGLDXGLNeedsFinish, bool, false);
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -4920,17 +4920,16 @@ pref("webgl.max-contexts", 16);
 pref("webgl.max-contexts-per-principal", 8);
 #else
 pref("webgl.max-contexts", 32);
 pref("webgl.max-contexts-per-principal", 16);
 #endif
 pref("webgl.max-warnings-per-context", 32);
 pref("webgl.enable-draft-extensions", false);
 pref("webgl.enable-privileged-extensions", false);
-pref("webgl.bypass-shader-validation", false);
 pref("webgl.disable-fail-if-major-performance-caveat", false);
 pref("webgl.disable-DOM-blit-uploads", false);
 pref("webgl.allow-fb-invalidation", false);
 
 pref("webgl.perf.max-warnings", 0);
 pref("webgl.perf.max-acceptable-fb-status-invals", 0);
 pref("webgl.perf.spew-frame-allocs", true);