-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] More efficient usage of transient onscreen attachments. #51206
[Impeller] More efficient usage of transient onscreen attachments. #51206
Conversation
matanlurey
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Someone with more context on the implications of this change should give final LGTM - I mostly reviewed agnostically (though I remember some words!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to go and add a comment to SurfaceVK::WrapSwapchainImage (in the .h).
Based on what you told me, maybe something like:
Wraps a swapchain image for rendering with MSAA and depth/stencil support.
This function takes an device(?)-provided swapchain image (which is the resolve target
of a potential MSAA render process) and prepares it for use by creating necessary
supporting textures. This includes the MSAA texture (if enabled) and the depth/stencil
texture for rendering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doc comment added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of scope of this PR, but why do we have this code:
if (!context || !swapchain_image || !swap_callback) {
return nullptr;
}When is it valid not to have these things? I'm in particular confused about swap_callback, because below:
bool SurfaceVK::Present() const {
return swap_callback_ ? swap_callback_() : false;
}It's impossible for this to be null, right?
|
|
||
| RenderTarget render_target_desc; | ||
| render_target_desc.SetColorAttachment(color0, 0u); | ||
| render_target_desc.SetupDepthStencilAttachments( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we expand this with /*=param*/ comments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| vk::Image image_ = VK_NULL_HANDLE; | ||
| vk::UniqueImageView image_view_ = {}; | ||
| std::shared_ptr<Texture> msaa_tex_; | ||
| std::shared_ptr<Texture> msaa_texture_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for spelling out texture.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one was my fault initially
| TextureDescriptor msaa_desc; | ||
| msaa_desc.storage_mode = StorageMode::kDeviceTransient; | ||
| msaa_desc.type = TextureType::kTexture2DMultisample; | ||
| msaa_desc.sample_count = SampleCount::kCount4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are all these values picked/known?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a comment, but mostly it matches the swapchain + the convention we use.
| /// | ||
| virtual bool IsSwapchainImage() const = 0; | ||
|
|
||
| // These methods should only be used by render_pass_vk.h |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could friend be used instead of a comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would have to be friend for the class and all of the test classes. TBH I haven't figured out how to do that consistently for test classes, since the name is macro generated?
|
|
||
| auto texture = render_target.GetRenderTargetTexture(); | ||
| auto& texture_vk = TextureVK::Cast(*texture); | ||
| EXPECT_EQ(texture_vk.GetFramebuffer(), nullptr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the caching behavior truly imply these should start null?
If so, I wonder if the name is misleading (i.e. should be GetCachedFramebuffer). I might be missing something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes these start null, I updated the name to GetCachedFramebuffer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the test directly verify the "primary trick" outlined in the change context (recycling a single MSAA and Depth/Stencil attachment)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does now
|
|
||
| EXPECT_TRUE(swapchain->IsValid()); | ||
|
|
||
| // We should create 3 swapchain images with the current mock setup. However, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this enforced in the test somehow or an implied assumption?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can actually be fixed now. There were some global state problems, but @jason-simmons fixed up parts of the mock vulkan when he was doing the ASAN changes that make this easier to implemented.
Updated the test so we create all 3 swapchain images and can make assertions on them.
| auto texture = render_target.GetRenderTargetTexture(); | ||
| auto& texture_vk = TextureVK::Cast(*texture); | ||
|
|
||
| EXPECT_NE(texture_vk.GetFramebuffer(), nullptr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should improve the mocks if we're not able to make a more definitive assertion (i.e. if, as I think you are trying to do, assert that the frame buffer stays the same).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh yeah, I can go through once more and verify they are the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
7c4b31e to
e7b3a1b
Compare
matanlurey
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM from a purely this is code and I think it is good (TM) perspective.
dnfield
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's Get This Moving
…144839) flutter/engine@bc4abcd...05fdf94 2024-03-08 [email protected] [Impeller] More efficient usage of transient onscreen attachments. (flutter/engine#51206) 2024-03-08 6844906[email protected] [Fuchsia] Providing FUCHSIA_SDK_PATH env var for fuchsia lsc (flutter/engine#51234) 2024-03-08 [email protected] Migrate vulkan_memory_allocator to flutter/third_party (flutter/engine#51275) 2024-03-08 [email protected] Update CI scripts to use either src/flutter/third_party/dart or src/third_party/dart (flutter/engine#51276) 2024-03-08 [email protected] Add fuchsia_gn_sdk GN variable pointing to //flutter/tools/fuchsia/gn-sdk (flutter/engine#51287) 2024-03-08 [email protected] Roll Skia from 993a88a663c8 to a4fb847f47d9 (1 revision) (flutter/engine#51283) 2024-03-08 [email protected] Roll Skia from 15f8d03a9594 to 993a88a663c8 (1 revision) (flutter/engine#51282) 2024-03-08 [email protected] Roll Skia from 093994f8f078 to 15f8d03a9594 (1 revision) (flutter/engine#51280) 2024-03-08 [email protected] Roll Skia from bf3f9c5f0edb to 093994f8f078 (1 revision) (flutter/engine#51278) 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 [email protected],[email protected] 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
Work towards flutter/flutter#144617
Fixes flutter/flutter#141750