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

Enable Skia's Vulkan backend on all non-mobile platforms, and test SwiftShader Vulkan on all GL unittests platforms #29520

Merged
merged 18 commits into from Nov 16, 2021

Conversation

bdero
Copy link
Member

@bdero bdero commented Nov 4, 2021

  • Enables Skia's Vulkan backend on all platforms (which will be usable through the embedder API).
  • Gets SwiftShader Vulkan building anywhere the GL embedder unittests can run.
  • Adds a simple test that initializes Vulkan state with SwiftShader (full test harness integration to come).

Patches that need to land before this is merged:

@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.

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.

@google-cla google-cla bot added the cla: yes label Nov 4, 2021
@bdero bdero removed the needs tests label Nov 4, 2021
@bdero bdero force-pushed the bdero/minimal-vulkan-test branch 2 times, most recently from 27b0ad1 to ab2206e Compare November 4, 2021 19:54
@bdero bdero changed the title Add minimal test to verify Swiftshader Vulkan works WIP: Add minimal test to verify Swiftshader Vulkan works Nov 4, 2021
@bdero bdero force-pushed the bdero/minimal-vulkan-test branch 5 times, most recently from da7911f to b19b709 Compare November 8, 2021 20:19
@bdero bdero changed the title WIP: Add minimal test to verify Swiftshader Vulkan works WIP: Add minimal Swiftshader Vulkan test and get it building on all platforms where it's possible Nov 8, 2021
@bdero

This comment has been minimized.

@bdero bdero changed the title WIP: Add minimal Swiftshader Vulkan test and get it building on all platforms where it's possible WIP: Enable Skia's Vulkan backend on all platforms where possible and add minimal Swiftshader Vulkan test Nov 8, 2021
@bdero bdero force-pushed the bdero/minimal-vulkan-test branch 4 times, most recently from fc51cc3 to 5a6713e Compare November 9, 2021 08:32
@bdero bdero changed the title WIP: Enable Skia's Vulkan backend on all platforms where possible and add minimal Swiftshader Vulkan test WIP: Enable Skia's Vulkan backend on all platform Nov 10, 2021
@bdero bdero changed the title WIP: Enable Skia's Vulkan backend on all platform WIP: Enable Skia's Vulkan backend on all platforms Nov 10, 2021
@bdero bdero changed the title WIP: Enable Skia's Vulkan backend on all platforms Enable Skia's Vulkan backend on all platforms Nov 10, 2021
Copy link
Member

@chinmaygarde chinmaygarde left a comment

Choose a reason for hiding this comment

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

Mostly LGTM except I don't think setting shell_enable_vulkan to true unconditionally is what we want for iOS and Android.

public:
TestVulkanContext();
~TestVulkanContext();
bool is_valid();
Copy link
Member

Choose a reason for hiding this comment

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

Nit: bool IsValid() const;.

The case because its OOL and the const because of const-correctness.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

fml::RefPtr<vulkan::VulkanProcTable> vk_;
std::unique_ptr<vulkan::VulkanApplication> application_;
std::unique_ptr<vulkan::VulkanDevice> logical_device_;
};
Copy link
Member

Choose a reason for hiding this comment

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

FML_DISALLOW_COPY_AND_ASSIGN explicitly even though this can't really be copied because of the unique pointers.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

bool is_valid();

private:
bool valid_;
Copy link
Member

Choose a reason for hiding this comment

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

Default to false here in case we add additional ctors and forget to initialize the scalar explicitly in one of them? Your call.

Copy link
Member Author

Choose a reason for hiding this comment

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

sgtm, done.

#endif // VULKAN_LINK_STATICALLY
return !!handle_;
Copy link
Member

Choose a reason for hiding this comment

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

lol, I never thought of this to avoid an explicit bool cast without actually using an explicit cast. Love it.

tools/gn Outdated
@@ -308,6 +308,12 @@ def to_gn_args(args):
gn_args['skia_use_metal'] = True
gn_args['shell_enable_metal'] = True

# Enable Vulkan on all platforms.
gn_args['skia_use_vulkan'] = True
gn_args['shell_enable_vulkan'] = True
Copy link
Member

Choose a reason for hiding this comment

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

I believe this will compile the vulkan shell component even on iOS and Android. The desire is to compile Vulkan on all host unit-test targets right?

Copy link
Member Author

Choose a reason for hiding this comment

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

My intention was to enable Vulkan support for all libflutter platform distributions including iOS, so that embedder writers have the option to target just Vulkan and use translation ICDs like MoltenVK. Partially because I want it, but also just because we can. :)

Copy link
Member

Choose a reason for hiding this comment

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

With that, you run into the issue of bumping up the binary size on those target. And we are pretty sensitive to that metric.

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'll disable this for Android/iOS for the time being and leave a note since it's easier to flip on than flip off later.

@CaseyHillers CaseyHillers changed the base branch from master to main November 15, 2021 18:12
@bdero
Copy link
Member Author

bdero commented Nov 16, 2021

@chinmaygarde Could you give this another look when you get a moment? I think this should be good to go.

@zanderso zanderso changed the base branch from master to main November 16, 2021 23:25
@bdero bdero merged commit bba38c0 into flutter:main Nov 16, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 17, 2021
… test SwiftShader Vulkan on all GL unittests platforms (flutter/engine#29520)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 17, 2021
… test SwiftShader Vulkan on all GL unittests platforms (flutter/engine#29520)
@knopp
Copy link
Member

knopp commented Nov 17, 2021

How is this supposed to work on macos? I get build error when it tries to compile //fluter/vulkan, possibly as part of open gl tests.

@bdero
Copy link
Member Author

bdero commented Nov 17, 2021

@knopp The embedder unittests link Swiftshader, which is one of several Vulkan ICDs that support MacOS. Could you open an issue with the error you're getting/repro steps and tag me on it?

@knopp
Copy link
Member

knopp commented Nov 17, 2021

@bdero, nevermind, I think the problem was missing skia_use_vulkan in args.gn.

bdero added a commit to bdero/flutter-engine that referenced this pull request Nov 17, 2021
Previous commit: flutter@cdbb428

Add test context for loading swiftshader so

update

Remove unused things

Prereqs to GPUSurfaceVulkan rewrite

Comment typos
cbracken added a commit to cbracken/flutter_engine that referenced this pull request Nov 17, 2021
… test SwiftShader Vulkan on all GL unittests platforms (flutter#29520)"

Causes the following build breakage (Win32):

    [19/1564] CXX obj/flutter/vulkan/vulkan.vulkan_window.obj
    FAILED: obj/flutter/vulkan/vulkan.vulkan_window.obj
    ninja -t msvc -e environment.x64 --
    ../../buildtools/windows-x64/clang/bin/clang-cl.exe  /nologo
    /showIncludes @obj/flutter/vulkan/vulkan.vulkan_window.obj.rsp /c
    ../../flutter/vulkan/vulkan_window.cc
     /Foobj/flutter/vulkan/vulkan.vulkan_window.obj
     /Fdobj/flutter/vulkan/vulkan_cc.pdb
     ../../flutter/vulkan/vulkan_window.cc(125,24): error: no member named
     'MakeVulkan' in 'GrDirectContext'
           GrDirectContext::MakeVulkan(backend_context, options);
                 ~~~~~~~~~~~~~~~~~^
                 1 error generated.

This reverts commit bba38c0.
bdero added a commit to bdero/flutter-engine that referenced this pull request Nov 19, 2021
Previous commit: flutter@cdbb428

Add test context for loading swiftshader so

update

Remove unused things

Prereqs to GPUSurfaceVulkan rewrite

Comment typos
bdero added a commit to bdero/flutter-engine that referenced this pull request Dec 2, 2021
Previous commit: flutter@cdbb428

Add test context for loading swiftshader so

update

Remove unused things

Prereqs to GPUSurfaceVulkan rewrite

Comment typos
bdero added a commit to bdero/flutter-engine that referenced this pull request Dec 2, 2021
Previous commit: flutter@cdbb428

Add test context for loading swiftshader so

update

Remove unused things

Prereqs to GPUSurfaceVulkan rewrite

Comment typos
bdero added a commit to bdero/flutter-engine that referenced this pull request Dec 9, 2021
Previous commit: flutter@cdbb428

Add test context for loading swiftshader so

update

Remove unused things

Prereqs to GPUSurfaceVulkan rewrite

Comment typos
bdero added a commit to bdero/flutter-engine that referenced this pull request Dec 13, 2021
Previous commit: flutter@cdbb428

Add test context for loading swiftshader so

update

Remove unused things

Prereqs to GPUSurfaceVulkan rewrite

Comment typos
bdero added a commit to bdero/flutter-engine that referenced this pull request Dec 14, 2021
Previous commit: flutter@cdbb428

Add test context for loading swiftshader so

update

Remove unused things

Prereqs to GPUSurfaceVulkan rewrite

Comment typos
bdero added a commit to bdero/flutter-engine that referenced this pull request Dec 15, 2021
Previous commit: flutter@cdbb428

Add test context for loading swiftshader so

update

Remove unused things

Prereqs to GPUSurfaceVulkan rewrite

Comment typos
bdero added a commit to bdero/flutter-engine that referenced this pull request Jan 11, 2022
Previous commit: flutter@cdbb428

Add test context for loading swiftshader so

update

Remove unused things

Prereqs to GPUSurfaceVulkan rewrite

Comment typos
bdero added a commit to bdero/flutter-engine that referenced this pull request Jan 20, 2022
Previous commit: flutter@cdbb428

Add test context for loading swiftshader so

update

Remove unused things

Prereqs to GPUSurfaceVulkan rewrite

Comment typos
bdero added a commit to bdero/flutter-engine that referenced this pull request Jan 24, 2022
Previous commit: flutter@cdbb428

Add test context for loading swiftshader so

update

Remove unused things

Prereqs to GPUSurfaceVulkan rewrite

Comment typos
bdero added a commit to bdero/flutter-engine that referenced this pull request Jan 28, 2022
Previous commit: flutter@cdbb428

Add test context for loading swiftshader so

update

Remove unused things

Prereqs to GPUSurfaceVulkan rewrite

Comment typos
bdero added a commit to bdero/flutter-engine that referenced this pull request Jan 31, 2022
Previous commit: flutter@cdbb428

Add test context for loading swiftshader so

update

Remove unused things

Prereqs to GPUSurfaceVulkan rewrite

Comment typos
bdero added a commit to bdero/flutter-engine that referenced this pull request Jan 31, 2022
Previous commit: flutter@cdbb428

Add test context for loading swiftshader so

update

Remove unused things

Prereqs to GPUSurfaceVulkan rewrite

Comment typos
bdero added a commit to bdero/flutter-engine that referenced this pull request Feb 2, 2022
Previous commit: flutter@cdbb428

Add test context for loading swiftshader so

update

Remove unused things

Prereqs to GPUSurfaceVulkan rewrite

Comment typos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants