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

Reland "[Windows] Move to FlutterCompositor for rendering" #49726

Merged
merged 2 commits into from
Jan 16, 2024

Conversation

loic-sharma
Copy link
Member

@loic-sharma loic-sharma commented Jan 11, 2024

Original pull request description

This migrates the Windows embedder to FlutterCompositor so that the engine renders off-screen to a framebuffer instead of directly onto the window's surface. This will allow us to support platform views and multiple views on Windows.

Addresses flutter/flutter#128904

Reland (again)

#49262 was reverted as it regressed package:material_floating_search_bar_2. See: flutter/flutter#140828

This pull request is split into the following commits:

  1. d337378 is the previous reland pull request, unchanged
  2. e866af0 disables the scissor test before blitting the framebuffer, allowing us to "force" copy the framebuffer's contents by ignoring scissoring values

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Comment on lines 137 to 139
gl_->Disable(GL_SCISSOR_TEST);
gl_->Disable(GL_DEPTH_TEST);
gl_->Disable(GL_STENCIL_TEST);
Copy link
Member Author

@loic-sharma loic-sharma Jan 11, 2024

Choose a reason for hiding this comment

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

This is new: disable the scissor test

EDIT: Updated after addressing feedback

Copy link
Member

@bdero bdero Jan 12, 2024

Choose a reason for hiding this comment

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

I don't think you need to worry about the depth/stencil state here. Just the scissor. The 4.6 spec says:

When values are written to the draw buffers, blit operations bypass most of the
fragment pipeline. The only fragment operations which affect a blit are the pixel
ownership test, the scissor test, and sRGB conversion (see section 17.3.7). Color,
depth, and stencil masks (see section 17.4.2) are ignored.

Copy link
Member Author

@loic-sharma loic-sharma Jan 16, 2024

Choose a reason for hiding this comment

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

Looks like you're right: the fix still works if we disable only the scissor test. Updated!

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.

Not that it should block this change, but does Impeller still work with this configuration?

@loic-sharma loic-sharma force-pushed the windows_compositor_v3 branch from 096c847 to fb075db Compare January 11, 2024 21:27
@loic-sharma
Copy link
Member Author

loic-sharma commented Jan 12, 2024

@jonahwilliams It does not. Impeller invokes FlutterOpenGLRendererConfig.fbo_with_frame_info_callback, which now immediately exits on Windows since the engine should be rendering to a backing store instead of the window's surface

@loic-sharma loic-sharma marked this pull request as ready for review January 12, 2024 00:59
@jonahwilliams
Copy link
Member

Thanks for checking! Can you file a bug for us with some information on what we need to update to make it work again?

Copy link
Member

@cbracken cbracken left a comment

Choose a reason for hiding this comment

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

LGTM stamp from a Japanese personal seal

@@ -48,7 +48,7 @@ static std::optional<GLuint> ConfigureFBO(
}

if (gl.CheckFramebufferStatus(fbo_type) != GL_FRAMEBUFFER_COMPLETE) {
VALIDATION_LOG << "Could not create a complete frambuffer.";
VALIDATION_LOG << "Could not create a complete framebuffer.";
Copy link
Member

Choose a reason for hiding this comment

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

frambuffer: most, but not quite all, of a framebuffer. 🤣

shell/platform/linux/fl_backing_store_provider.cc Outdated Show resolved Hide resolved
@azchohfi
Copy link

Would this break Windows 7 compatibility, or is this being used only if Win8+?
We might need to wait for flutter/flutter#140830

@loic-sharma
Copy link
Member Author

@azchohfi For now we still fully support Windows 7. This PR doesn't use DirectComposition - is that your concern?

@loic-sharma
Copy link
Member Author

@jonahwilliams Sure! Opened: flutter/flutter#141482.

@azchohfi
Copy link

@azchohfi For now we still fully support Windows 7. This PR doesn't use DirectComposition - is that your concern?

I completely misread the PR, ignore my comment. My bad.

@loic-sharma loic-sharma force-pushed the windows_compositor_v3 branch from ff7d3b2 to 7c8da79 Compare January 16, 2024 21:22
@loic-sharma loic-sharma force-pushed the windows_compositor_v3 branch from 7c8da79 to e866af0 Compare January 16, 2024 21:28
@loic-sharma loic-sharma added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 16, 2024
@auto-submit auto-submit bot merged commit 9525c1a into flutter:main Jan 16, 2024
29 checks passed
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jan 17, 2024
…141651)

flutter/engine@d4b6b7e...021a5ff

2024-01-16 ditman@gmail.com [web] Leave blob URLs untouched in TT policy. (flutter/engine#49782)
2024-01-16 jason-simmons@users.noreply.github.com [Impeller] Fix a race between SwapchainImplVK::Present and WaitForFence (flutter/engine#49777)
2024-01-16 737941+loic-sharma@users.noreply.github.com Reland "[Windows] Move to FlutterCompositor for rendering" (flutter/engine#49726)
2024-01-16 jason-simmons@users.noreply.github.com [Impeller] Add an API for sampling strictly within the bounds of the source rect in DrawImageRect (flutter/engine#49696)
2024-01-16 jonahwilliams@google.com [Impeller] Encode directly to command buffer for Vulkan. (flutter/engine#49780)

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 jonahwilliams@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
auto-submit bot added a commit to flutter/flutter that referenced this pull request Jan 17, 2024
…isions)" (#141659)

Reverts #141651
Initiated by: jonahwilliams
This change reverts the following previous change:
Original Description:

flutter/engine@d4b6b7e...021a5ff

2024-01-16 ditman@gmail.com [web] Leave blob URLs untouched in TT policy. (flutter/engine#49782)
2024-01-16 jason-simmons@users.noreply.github.com [Impeller] Fix a race between SwapchainImplVK::Present and WaitForFence (flutter/engine#49777)
2024-01-16 737941+loic-sharma@users.noreply.github.com Reland "[Windows] Move to FlutterCompositor for rendering" (flutter/engine#49726)
2024-01-16 jason-simmons@users.noreply.github.com [Impeller] Add an API for sampling strictly within the bounds of the source rect in DrawImageRect (flutter/engine#49696)
2024-01-16 jonahwilliams@google.com [Impeller] Encode directly to command buffer for Vulkan. (flutter/engine#49780)

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 jonahwilliams@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
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jan 17, 2024
…141664)

flutter/engine@d4b6b7e...1382ff7

2024-01-16 magder@google.com Remove iOS 12 availability checks (flutter/engine#49771)
2024-01-16 30870216+gaaclarke@users.noreply.github.com [Impeller] generate mipmaps for imagefilters (flutter/engine#49794)
2024-01-16 ditman@gmail.com [web] Leave blob URLs untouched in TT policy. (flutter/engine#49782)
2024-01-16 jason-simmons@users.noreply.github.com [Impeller] Fix a race between SwapchainImplVK::Present and WaitForFence (flutter/engine#49777)
2024-01-16 737941+loic-sharma@users.noreply.github.com Reland "[Windows] Move to FlutterCompositor for rendering" (flutter/engine#49726)
2024-01-16 jason-simmons@users.noreply.github.com [Impeller] Add an API for sampling strictly within the bounds of the source rect in DrawImageRect (flutter/engine#49696)
2024-01-16 jonahwilliams@google.com [Impeller] Encode directly to command buffer for Vulkan. (flutter/engine#49780)

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 jonahwilliams@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
@knopp
Copy link
Member

knopp commented Mar 21, 2024

Just to be clear, this change introduced an extra blit that's always there? What exactly is the reason for it? Why not use the back framebuffer?

@loic-sharma
Copy link
Member Author

loic-sharma commented Mar 25, 2024

@knopp and I talked on Discord, but I'll capture our conversation here as well in case other folks have the same question.

Currently the engine's backing stores are interchangeable if they have the same size. The intermediary textures plus extra blit allow us to render to multiple views while keeping this interchangeable model, with the trade-off of higher memory usage.

We plan to have a conversation with the engine team to see if we can "tie" backing stores to a view. We expect this would require some minor embedder API changes. See: http://flutter.dev/go/backing-stores-for-multi-view-partial-repaint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

7 participants