Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Impeller] Implement framebuffer-fetch via subpasses in Vulkan without extensions. #50154

Merged
merged 2 commits into from
Jan 31, 2024

Conversation

chinmaygarde
Copy link
Member

@chinmaygarde chinmaygarde commented Jan 29, 2024

  • Subpasses are not exposed in the HAL and the need for subpasses in Vulkan can
    be determined based on the presence and use of input-attachments in the
    shaders. This information is already reflected by the compiler. Because of
    this, all references to subpasses have been removed from APIs above the HAL.
  • RenderPassBuilderVK is a lightweight object used to generate render passes
    to use either with the pipelines (compat, base, or per-subpass) or during
    rendering along with the framebuffer. Using the builder also sets up the
    right subpass dependencies. As long as the builder contains compatible
    attachments and subpass counts, different subpasses stamped by the builder
    (via the Build method) are guaranteed to be compatible per the rules in the
    spec.
  • Pass attachments are now in the eGeneral layout. There was no observable
    difference in performance when manually inserting the right transitions.
    Except, a lot of transitions needed to be inserted. If we need it, we can add
    it back in short order. I wouldn't be averse to adding it if reviewers
    insist.
  • Additional pipeline state objects need not be created as the sub-pass
    self-dependencies are sufficient to setup the render-pass.
  • Speaking of the rasterization_order_attachment_access extension, its use has
    been removed in this patch. I am prototyping adding it back to measure the
    overhead introduced by manual subpass management. If the overhead is
    measurable, we can use the extension on devices that have it as an added
    optimization.
  • The complexity of command encoding remains linear (to the number of commands)
    per pass.
  • This patch only works on a single color attachment being used as an input
    attachment. While this is sufficient for current use cases, the Metal
    implementation is significantly more capable since the multiple attachments
    and attachment types (depth) are already supported. Rounding out support for
    this is in progress.

@chinmaygarde
Copy link
Member Author

I was able to reproduce and fix the clips breaking as reported in #49787 (comment). It was due to a stencil being cleared that should no longer be an issue in this patch. I haven't been able to reproduce the issue reported on a Samsung Android phone because I don't have access to one.

@jonahwilliams
Copy link
Member

Awesome, checking this out - quick pass with a few questions.

impeller/renderer/backend/vulkan/render_pass_vk.cc Outdated Show resolved Hide resolved
if (supports_framebuffer_fetch) {
vk_usage |= vk::ImageUsageFlagBits::eInputAttachment;
}
vk_usage |= vk::ImageUsageFlagBits::eInputAttachment;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this only for color attachments?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use subpassLoad on any image. If a depth-stencil image is set in the descriptor, that will work too as long as there is sufficient synchronization. So, no. Though I just removed this code since supports_framebuffer_fetch will always be true in this code.

impeller/renderer/backend/vulkan/formats_vk.h Outdated Show resolved Hide resolved
@jonahwilliams
Copy link
Member

This is working for me locally with a pixel and an older galaxy

return pipeline;
}

TEST_P(RendererTest, CanSepiaToneWithSubpasses) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK (@gaaclarke correct me) but this test file doesn't have goldens right? Do we have sufficient golden coverage in aiks?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, the goldens happen in AiksTest, not here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. Do we have goldens coverage for any advanced blend already?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we depend on host testing, I'm not sure if anything in our matrix supports fb fetch. Metal desktop only supports it on arm.

Maybe since this path is unconditional swiftshader will still use it and the advanced blends will be covered?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unconditionality of these tests mean that these will only run on devices that support framebuffer-fetch. I forgot to add a skip otherwise. But yeah, on CI, these tests will only work on Vulkan and ARM Macs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but these tests as written are playground tests that aren't golden, so they don't run on CI AFAIK

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may run, but the test is more like ["does it compile", "does it run without crashing"]. I'm not sure about "passes validation" and we know "results are correct" isn't checked. Making sure that impeller_golden_tests is executing it makes sure we have the later 2 checks.

Copy link
Member

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really exciting!

@jonahwilliams
Copy link
Member

Clips still appear broken when I run the wonderous app on either a Pixel 7 or a Samsung

flutter_02

@flutter-dashboard

This comment was marked as outdated.

…t extensions.

* Subpasses are not exposed in the HAL and the need for subpasses in Vulkan can
  be determined based on the presence and use of input-attachments in the
  shaders. This information is already reflected by the compiler. Because of
  this, all references to subpasses have been removed from APIs above the HAL.
* `RenderPassBuilderVK` is a lightweight object used to generate render passes
  to use either with the pipelines (compat, base, or per-subpass) or during
  rendering along with the framebuffer. Using the builder also sets up the
  right subpass dependencies. As long as the builder contains compatible
  attachments and subpass counts, different subpasses stamped by the builder
  (via the `Build` method) are guaranteed to be compatible per the rules in the
  spec.
* Pass attachments are now in the `eGeneral` layout. There was no observable
  difference in performance when manually inserting the right transitions.
  Except, a lot of transitions needed to be inserted. If we need it, we can add
  it back in short order. I wouldn't be averse to adding it if reviewers
  insist.
* Additional pipeline state objects need not be created as the sub-pass
  self-dependencies are sufficient to setup the render-pass.
* Speaking of the `rasterization_order_attachment_access` extension, its use has
  been removed in this patch. I am prototyping adding it back to measure the
  overhead introduced by manual subpass management. If the overhead is
  measurable, we can use the extension on devices that have it as an added
  optimization.
* The complexity of command encoding remains linear (to the number of commands)
  per pass.
* This patch only works on a single color attachment being used as an input
  attachment. While this is sufficient for current use cases, the Metal
  implementation is significantly more capable since the multiple attachments
  and attachment types (depth) are already supported. Rounding out support for
  this is in progress.
@chinmaygarde
Copy link
Member Author

okie dokie, the test failures have been addressed, the clips work now too and are covered by the golden tests and I think I've addressed all PR comments. PTAL.

Copy link
Member

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM

I would prefer it if the additional test coverage either added some goldens or something that we could catch on CI.

@jonahwilliams
Copy link
Member

Work towards flutter/flutter#120223

@jonahwilliams
Copy link
Member

Also word of warning, if you force push skia gold won't rerun. I would probably update branch at least once and let it run to verify that there are no regressions.

@chinmaygarde
Copy link
Member Author

I updated the branch and the goldens seem to be happy. Assuming everything is good. Landing this and working on the new goldens next.

@chinmaygarde chinmaygarde added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 31, 2024
@auto-submit auto-submit bot merged commit f4fbabf into flutter:main Jan 31, 2024
29 checks passed
@chinmaygarde chinmaygarde deleted the pass6 branch January 31, 2024 23:32
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 1, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Feb 1, 2024
…142675)

flutter/engine@c4247c5...f4fbabf

2024-01-31 chinmaygarde@google.com [Impeller] Implement framebuffer-fetch via subpasses in Vulkan without extensions. (flutter/engine#50154)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC matanl@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App e: impeller will affect goldens
Projects
No open projects
Status: ✅ Done
3 participants