Verified Commit bfbe3d3a authored by Lee Salzman's avatar Lee Salzman Committed by ma1
Browse files

Bug 2045741. a=RyanVM DONTBUILD

parent 58795e1f
Loading
Loading
Loading
Loading
+29 −8
Original line number Diff line number Diff line
@@ -897,6 +897,7 @@ void WebGLProgram::LinkProgram() {
  // (Work around for bug seen on nVidia drivers.)
  std::vector<std::string> scopedMappedTFVaryings;

  bool allowLink = true;
  if (mContext->IsWebGL2()) {
    mVertShader->MapTransformFeedbackVaryings(
        mNextLink_TransformFeedbackVaryings, &scopedMappedTFVaryings);
@@ -907,11 +908,20 @@ void WebGLProgram::LinkProgram() {
      driverVaryings.push_back(cur.c_str());
    }

    // If the driver rejects the varyings (e.g. reserved gl_* names), the
    // program object keeps the previous link's pending transform-feedback
    // state. Instead, avoid trying to link with the stale state.
    gl::GLContext::LocalErrorScope errorScope(*mContext->gl);
    mContext->gl->fTransformFeedbackVaryings(
        mGLName, driverVaryings.size(), driverVaryings.data(),
        mNextLink_TransformFeedbackBufferMode);
    if (errorScope.GetError()) {
      allowLink = false;
      mLinkLog = "Driver rejected the requested transform feedback varyings.";
    }
  }

  if (allowLink) {
    LinkAndUpdate();

    if (mMostRecentLinkInfo) {
@@ -921,6 +931,7 @@ void WebGLProgram::LinkProgram() {
      mMostRecentLinkInfo = nullptr;
      mLinkLog = std::move(postLinkLog);
    }
  }

  // Failed link.
  if (mContext->ShouldGenerateWarnings()) {
@@ -1062,8 +1073,14 @@ bool WebGLProgram::ValidateAfterTentativeLink(

  // Forbid too many components for specified buffer mode
  const auto& activeTfVaryings = linkInfo->active.activeTfVaryings;
  MOZ_ASSERT(mNextLink_TransformFeedbackVaryings.size() ==
             activeTfVaryings.size());
  // The driver reported different varyings than requested, which might occur
  // if there was somehow stale or invalid transform-feedback state.
  if (mNextLink_TransformFeedbackVaryings.size() != activeTfVaryings.size()) {
    *out_linkLog =
        "Mismatch between requested and driver-reported active transform"
        " feedback varyings.";
    return false;
  }
  if (!activeTfVaryings.empty()) {
    GLuint maxComponentsPerIndex = 0;
    switch (linkInfo->transformFeedbackBufferMode) {
@@ -1193,6 +1210,10 @@ void WebGLProgram::TransformFeedbackVaryings(
      GLuint maxAttribs = 0;
      gl->GetUIntegerv(LOCAL_GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS,
                       &maxAttribs);
      // While we report the conservative constant limit, the driver might
      // support less. Try to catch that here early rather than at link.
      maxAttribs = std::min(
          maxAttribs, GLuint(webgl::kMaxTransformFeedbackSeparateAttribs));
      if (varyings.size() > maxAttribs) {
        mContext->ErrorInvalidValue("Length of `varyings` exceeds %s.",
                                    "TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS");