Skip to content

[Impeller] GLES only rendering bug when switching to DL provided depth values. #153504

Closed
flutter-team-archive/engine
#56310

Description

@jonahwilliams

The test is impeller_Play_AiksTest_CanRenderDifferenceClips_OpenGLES . It looks like the entities after the clip restore don't have the right value? Not sure.

image

Activity

  1. added
    P2Important issues not at the top of the work list
    on Aug 19, 2024
  2. jonahwilliams commented on Aug 19, 2024

    @jonahwilliams
    ContributorAuthor

    @chinmaygarde might be something to do with the depth clamp or depth clamp values.

    We could be missing some sort of normalization.

  3. self-assigned this
    on Nov 1, 2024
  4. jonahwilliams commented on Nov 1, 2024

    @jonahwilliams
    ContributorAuthor

    I've confirmed that this only happens with path draws, and not with rectangular draws. I suspect a problem in StC interaction with depth clips.

  5. jonahwilliams commented on Nov 1, 2024

    @jonahwilliams
    ContributorAuthor

    If I force the stencil cover depth to be 1 greater, it renders correctly.

    This leads me to believe that something is a >= that should be a > or vice versa.

  6. chinmaygarde commented on Nov 1, 2024

    @chinmaygarde
    Contributor

    We might be investigating the same issue #157885. I'm trying to compare the Metal commands emitted by Angle and our Metal backend directly to see where the mismatch is. The issue does reproduce.

  7. jonahwilliams commented on Nov 1, 2024

    @jonahwilliams
    ContributorAuthor
  8. jonahwilliams commented on Nov 1, 2024

    @jonahwilliams
    ContributorAuthor

    right now if I save clip draw restore draw I can observe that clip 1 and draw 2 end up with the same depth value. i don't know why this works in metal/vulkan and not GL...

  9. chinmaygarde commented on Nov 1, 2024

    @chinmaygarde
    Contributor

    i don't know why this works in metal/vulkan and not GL...

    Yeah, that's the worrying bit. I double checked all the enum values. Getting a bit stuck with Xcode not telling me the depth stencil states.

  10. jonahwilliams commented on Nov 1, 2024

    @jonahwilliams
    ContributorAuthor
  11. 2 remaining items

  12. jonahwilliams commented on Nov 1, 2024

    @jonahwilliams
    ContributorAuthor

    Yeah it seems like GL is behaving correctly here while the other backends are actually buggy...

  13. chinmaygarde commented on Nov 1, 2024

    @chinmaygarde
    Contributor

    This "fixes" it.

    Screenshot 2024-11-01 at 11 56 43 AM
  14. chinmaygarde commented on Nov 1, 2024

    @chinmaygarde
    Contributor

    I should say, it fixes my test case, it breaks the CanRenderDifferenceClips case.

  15. jonahwilliams commented on Nov 1, 2024

    @jonahwilliams
    ContributorAuthor

    @chinmaygarde can you confirm if flutter-team-archive/engine#56310 fixes your bug too?

  16. chinmaygarde commented on Nov 1, 2024

    @chinmaygarde
    Contributor

    Yes it does.

    Screenshot 2024-11-01 at 12 29 08 PM 1

    The test case:

    TEST_P(AiksTest, GithubIssue157885) {
    #if FML_OS_MACOSX
      if (GetBackend() == PlaygroundBackend::kVulkan) {
        GTEST_SKIP() << "Unsupported on Molten due to usage of triangle fans.";
      }
    #endif  // FML_OS_MACOSX
      DisplayListBuilder builder;
    
      DlPaint paint;
      DlColor clear_color(1.0, 0.5, 0.5, 0.5, DlColorSpace::kSRGB);
      paint.setColor(clear_color);
      builder.DrawPaint(paint);
    
      DlMatrix identity = {
          1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0,
          0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0,
      };
      builder.Save();
      builder.Transform(identity);
    
      DlRect frame = DlRect::MakeLTRB(1.0, 1.0, 1278.0, 763.0);
      DlColor white(1.0, 1.0, 1.0, 1.0, DlColorSpace::kSRGB);
      paint.setColor(white);
      builder.DrawRect(frame, paint);
    
      builder.Save();
      builder.ClipRect(frame, DlCanvas::ClipOp::kIntersect);
    
      DlMatrix rect_xform = {
          0.8241262, 0.56640625, 0.0, 0.0, -0.56640625, 0.8241262, 0.0, 0.0,
          0.0,       0.0,        1.0, 0.0, 271.1137,    489.4733,  0.0, 1.0,
      };
      builder.Save();
      builder.Transform(rect_xform);
    
      DlRect rect = DlRect::MakeLTRB(0.0, 0.0, 100.0, 100.0);
      DlColor bluish(1.0, 0.184, 0.501, 0.929, DlColorSpace::kSRGB);
      paint.setColor(bluish);
      DlRoundRect rrect = DlRoundRect::MakeRectRadius(rect, 18.0);
      builder.DrawRoundRect(rrect, paint);
    
      builder.Save();
      builder.ClipRect(rect, DlCanvas::ClipOp::kIntersect);
      builder.Restore();
    
      builder.Restore();
    
      DlMatrix path_xform = {
          1.0, 0.0, 0.0, 0.0, 0.0,   1.0,   0.0, 0.0,
          0.0, 0.0, 1.0, 0.0, 675.0, 279.5, 0.0, 1.0,
      };
      builder.Save();
      builder.Transform(path_xform);
    
      SkPath path;
      path.moveTo(87.5, 349.5);
      path.lineTo(25.0, 29.5);
      path.lineTo(150.0, 118.0);
      path.lineTo(25.0, 118.0);
      path.lineTo(150.0, 29.5);
      path.close();
    
      DlColor fill_color(1.0, 1.0, 0.0, 0.0, DlColorSpace::kSRGB);
      DlColor stroke_color(1.0, 0.0, 0.0, 0.0, DlColorSpace::kSRGB);
      paint.setColor(fill_color);
      paint.setDrawStyle(DlDrawStyle::kFill);
      builder.DrawPath(DlPath(path), paint);
    
      paint.setColor(stroke_color);
      paint.setStrokeWidth(2.0);
      paint.setDrawStyle(DlDrawStyle::kStroke);
      builder.DrawPath(path, paint);
    
      builder.Restore();
      builder.Restore();
      builder.Restore();
    
      ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
    }
    
  17. chinmaygarde commented on Nov 1, 2024

    @chinmaygarde
    Contributor

    I labeled the depth stencil states and verified the enums. I don't think its anything to do with how we configure GL state. Shader precision perhaps?

  18. jonahwilliams commented on Nov 1, 2024

    @jonahwilliams
    ContributorAuthor

    ghosts in the machine

  19. chinmaygarde commented on Nov 1, 2024

    @chinmaygarde
    Contributor

    I attempted to debug the vertices and the effective shaders are the same. Only OpenGL has an additional transformation to the z to make the coordinate systems line up.

    Screenshot 2024-11-01 at 12 46 29 PM
  20. github-actions commented on Nov 15, 2024

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  21. locked as resolved and limited conversation to collaborators on Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work liste: impellerImpeller rendering backend issues and features requestse: openglteam-engineOwned by Engine teamtriaged-engineTriaged by Engine team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions