-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] Wire Flutter's own VulkanMemoryAllocator
implementation
#37018
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. |
030a7ed
to
6abf1dd
Compare
10b160b
to
b80cffe
Compare
6c08717
to
07d8b8f
Compare
VulkanMemoryAllocator
implementationVulkanMemoryAllocator
implementation
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.
Oof, didn't realize chasing all the uses of Vulkan context creation would be so tedious. Thanks for doing this!
Left some comments on how Impeller ought to use VMA but there are just informational.
|
||
namespace flutter { | ||
|
||
class FlutterSkiaVulkanMemoryAllocator : public skgpu::VulkanMemoryAllocator { |
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.
Nit: Perhaps just call this SkiaVulkanMemoryAllocator
?
// devices are required to support a host visible and coherent memory type. | ||
// This is used to work around bugs for devices that don't handle non coherent | ||
// memory correctly. | ||
bool must_use_coherent_host_visible_memory_; |
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.
Disallow copy and assign here?
// this type of memory. But if we ever do we could pass in an | ||
// AllocationPropertyFlag that requests the cached property. | ||
info.requiredFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | | ||
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; |
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.
In case of Impeller, we should never require VK_MEMORY_PROPERTY_HOST_COHERENT_BIT as we will always have the corresponding map-unmap pairs.
info.requiredFlags |= VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; | ||
} | ||
if (kDedicatedAllocation_AllocationPropertyFlag & allocationPropertyFlags) { | ||
info.flags |= VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT; |
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 reminds me, perhaps we should do this for all images from the image decoder (the ui.Images)?
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.
Noted, will fix this in allocator_vk.cc
} | ||
if ((kLazyAllocation_AllocationPropertyFlag & allocationPropertyFlags) && | ||
BufferUsage::kGpuOnly == usage) { | ||
info.preferredFlags |= VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT; |
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.
In Impellers case, this would be the device transient types.
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.
Noted, will fix this in allocator_vk.cc
|
||
if (kPersistentlyMapped_AllocationPropertyFlag & allocationPropertyFlags) { | ||
SkASSERT(BufferUsage::kGpuOnly != usage); | ||
info.flags |= VMA_ALLOCATION_CREATE_MAPPED_BIT; |
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 never needs this with Impeller.
] | ||
|
||
if (disable_vma_stl_shared_mutex) { | ||
defines = [ "VMA_USE_STL_SHARED_MUTEX=0" ] |
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 correct? Does this mean there is no thread safety around VMA access? Or does it mean there is a non-STL implementation of mutexes? If there is no thread safety, we'll need to follow up on implementing external synchronization in the Impeller case. Which might be the right thing to do anyway.
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 means that they use non-stl mutexes. For context, Impeller doesn't use flutter_skia_vma.cc
stuff at all. We just use allocator_vk.cc
copy of the vma.
auto label is removed for flutter/engine, pr: 37018, due to - The status or check suite Mac Host clang-tidy has failed. Please fix the issues identified (or deflake) before re-applying this label. |
Is this flake a couple of commits past this change related? https://ci.chromium.org/ui/p/flutter/builders/prod/Linux%20Production%20Engine%20Drone/5722/overview |
fixes: flutter/flutter#114030