Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[Impeller] Correct attachment description for offscreen MSAA resolve. #42753

Merged

Conversation

jonahwilliams
Copy link
Member

Two issues:

  1. The resolve texture is created from the same impeller attachment as the msaa attachment, so the store mode was getting set to dont care instead of store.

  2. the image layout for the resolve attachment should be ePresentSrcKHR, at least from following the guide at https://vulkan-tutorial.com/Multisampling

Fixing both of these locally fixes all of the weird offscreen cursed rendering.

Fixes flutter/flutter#128600

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@jonahwilliams
Copy link
Member Author

lol now we get a validation error. I think I just need to correct the layout info.

@jonahwilliams
Copy link
Member Author

hilariously I misread the tutorial, but visually things are fixed for me 😮‍💨

@jonahwilliams
Copy link
Member Author

So I suspect that rather than fixing this, the error has introduced some pessimization which is causing the synchronization issue to resolve itself.

Comment on lines 471 to 472
resolve_texture ? vk::ImageLayout::ePresentSrcKHR
: vk::ImageLayout::eColorAttachmentOptimal;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the right switch value?

Spec says that eColorAttachmentOptimal "must only" be used as a color ro resolve in a VkFramebuffer.

Perhaps the argument should instead be bool is_framebuffer or something? Or perhaps an enum where the enumerated values are something like kFramebuffer and kNonFramebuffer.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I really understand what ePresentSrcKHR is really for. Did you already try eGeneral?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't really understand either, but it was the value used in https://vulkan-tutorial.com/Multisampling so I just went with it. I'll try general

Copy link
Member Author

Choose a reason for hiding this comment

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

eGeneral works! lets see if it validates

@@ -95,7 +98,7 @@ SharedHandleVK<vk::RenderPass> RenderPassVK::CreateVKRenderPass(
if (color.resolve_texture) {
resolve_refs[bind_point] =
vk::AttachmentReference{static_cast<uint32_t>(attachments.size()),
vk::ImageLayout::eColorAttachmentOptimal};
vk::ImageLayout::ePresentSrcKHR};
Copy link
Contributor

Choose a reason for hiding this comment

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

(Ditto here: maybe eGeneral instead?)

@@ -49,14 +49,17 @@ static vk::AttachmentDescription CreateAttachmentDescription(

if (desc.storage_mode == StorageMode::kDeviceTransient) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the real problem that we're setting the storage mode to device transient?

I'm not quite clear on when we should set dontcare or not though.

Copy link
Member Author

Choose a reason for hiding this comment

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

no that doesn't seem to be it, at least things are already working for me

@jonahwilliams jonahwilliams requested a review from dnfield June 12, 2023 16:55
@@ -466,7 +467,9 @@ constexpr vk::AttachmentDescription CreateAttachmentDescription(
switch (kind) {
case AttachmentKind::kColor:
vk_attachment.initialLayout = current_layout;
vk_attachment.finalLayout = vk::ImageLayout::eColorAttachmentOptimal;
vk_attachment.finalLayout =
resolve_texture ? vk::ImageLayout::eGeneral
Copy link
Contributor

Choose a reason for hiding this comment

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

The nitpick here is using "resolve_texture" as the reason to do this.

The not nitpick here is that I think we should go with eGeneral unless we know for sure that this is for the framebuffer. eGeneral should always be safe if I'm understanding the spec, whereas the eColorAttachmentOptimal is only safe if we know we're using this for framebuffer.

@jonahwilliams jonahwilliams requested a review from dnfield June 12, 2023 17:16
@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 12, 2023
@auto-submit auto-submit bot merged commit 6e9db78 into flutter:main Jun 12, 2023
@jonahwilliams jonahwilliams deleted the fix_offscreen_msaa_configuration branch June 12, 2023 18:01
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 12, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jun 12, 2023
…128721)

flutter/engine@33e0693...de68fba

2023-06-12 [email protected] Fix crash with CJK keyboard with emoji at end of text field (flutter/engine#42540)
2023-06-12 [email protected] Roll Skia from 658b1d366758 to 6bdb0ef30cb6 (2 revisions) (flutter/engine#42778)
2023-06-12 [email protected] [Impeller] Correct attachment description for offscreen MSAA resolve. (flutter/engine#42753)
2023-06-12 [email protected] Remove dependency on memfs (flutter/engine#42773)
2023-06-12 [email protected] Roll Skia from 0f974a0f8c10 to 658b1d366758 (1 revision) (flutter/engine#42776)
2023-06-12 [email protected] Roll ANGLE from 3abbc4f99970 to 43ef50f389e9 (1 revision) (flutter/engine#42775)
2023-06-12 [email protected] Remove unnecessary #include of SkPromiseImageTexture (flutter/engine#42770)
2023-06-12 [email protected] Roll Skia from 951123096e55 to 0f974a0f8c10 (5 revisions) (flutter/engine#42771)
2023-06-12 [email protected] [Impeller] opt all vertex shader position/uvs into highp (flutter/engine#42746)
2023-06-12 [email protected] [Impeller] added debug info to frame debuggers like AGI (flutter/engine#42717)

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],[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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
autosubmit Merge PR when tree becomes green via auto submit App e: impeller needs tests
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[Impeller] Vulkan Offscreen MSAA is misconfigured.
2 participants