-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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] add explicit VMA flush to device memory writes. #42685
Conversation
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. |
@@ -46,6 +46,7 @@ bool DeviceBufferVK::OnCopyHostBuffer(const uint8_t* source, | |||
if (source) { | |||
::memmove(dest + offset, source + source_range.offset, source_range.length); | |||
} | |||
::vmaFlushAllocation(allocator_, allocation_, offset, source_range.length); |
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.
#ifdef FML_OS_ANDROID
?
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.
are you sure? we can't actually test all the devices this will run on, and this will always be safe to call...
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 think we should probably just not request coherent memory if we don't need it and add the explict flushes
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.
Ok.
It looks like we should be querying vmaGetMemoryProperties
to see if the https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkPhysicalDeviceMemoryProperties.html has a VkMemoryType that supports host coherent.
I think we should add a caps check and do the flush based on the caps.
I removed the coherent bit. If we add a cap check then we risk unreproducible failures if the flush gets deleted. |
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 LGTM, consider adding a comment on why we're not asking for HOST_COHERENT and that if we want to ask for it we need to have some kind of caps check.
I think we'd need some kind of golden test for this on Android - we can get to that once vulkan is available in something the devicelab can see, or maybe try to add one to scenario_app? |
…2685) According to my read of the documentation for VMA/Vulkan allocation docs, setting VK_MEMORY_PROPERTY_HOST_COHERENT_BIT means we shouldn't need to flush the memory. nevertheless, this fixes the corruption of host buffers observed in flutter/flutter#124040 Fixes flutter/flutter#124040 > VK_MEMORY_PROPERTY_HOST_COHERENT_BIT bit specifies that the host cache management commands [vkFlushMappedMemoryRanges](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkFlushMappedMemoryRanges.html) and [vkInvalidateMappedMemoryRanges](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkInvalidateMappedMemoryRanges.html) are not needed to flush host writes to the device or make device writes visible to the host, respectively. ð�¤·â��â��ï¸�
…128612) flutter/engine@071e1fb...488876e 2023-06-09 skia-flutter-autoroll@skia.org Roll ANGLE from a185cb8c8924 to 3e4f4caebcb0 (2 revisions) (flutter/engine#42701) 2023-06-09 bdero@google.com [Impeller] Add CPU implementations for all color filters (flutter/engine#42692) 2023-06-09 jonahwilliams@google.com [Impeller] add explicit VMA flush to device memory writes. (flutter/engine#42685) 2023-06-09 30870216+gaaclarke@users.noreply.github.com [Impeller] Makes validation layers flag work for android (flutter/engine#42625) 2023-06-09 jmccandless@google.com Platform channel for predictive back (flutter/engine#39208) 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 jacksongardner@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://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
According to my read of the documentation for VMA/Vulkan allocation docs, setting VK_MEMORY_PROPERTY_HOST_COHERENT_BIT means we shouldn't need to flush the memory. nevertheless, this fixes the corruption of host buffers observed in flutter/flutter#124040
Fixes flutter/flutter#124040
🤷♂️