taichi icon indicating copy to clipboard operation
taichi copied to clipboard

Create vulkan device failed on huawei phone(P40 pro , P40, Mate30 , Mate 30 Pro)

Open helloworldstone opened this issue 1 year ago • 5 comments

hi , everyone!

I want to use taichi vulkan AOT feature on Android.

When I create VulkanDevice with taichi C++ api, it failed with log "terminating with uncaught exception of type std::runtime_error: Error loading vulkan" on huawei phone(Mali GPU, HarmonyOS).

My test code shows as below: const std::vectorstd::string extensions = { VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_ANDROID_SURFACE_EXTENSION_NAME, VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, };

taichi::lang::vulkan::VulkanDeviceCreator::Params evd_params;
evd_params.api_version = std::nullopt;
evd_params.additional_instance_extensions = extensions;
evd_params.additional_device_extensions = {VK_KHR_SWAPCHAIN_EXTENSION_NAME};
evd_params.is_for_ui = false;
evd_params.surface_creator = nullptr;

std::unique_ptr<taichi::lang::vulkan::VulkanDeviceCreator> embedded_device_ =
    std::make_unique<taichi::lang::vulkan::VulkanDeviceCreator>(evd_params);

taichi::lang::vulkan::VulkanDevice* device_ = static_cast<taichi::lang::vulkan::VulkanDevice*>(
    embedded_device_->device());

It runs ok on Snapdragon 888(Adreno 660) and Dimensity 9000(Mali-G710).

I use cmake "add_executable" to compile my demo to a binary executable file.

I use taichi v1.1.2 to compile libtaichi_export_core.so.

So is there anything else that needs to be configured to create VulkanDevice on huawei phone(Mali GPU)?

Thanks a lot!

helloworldstone avatar Aug 28 '22 13:08 helloworldstone

cc: @ailzhang

strongoier avatar Aug 29 '22 08:08 strongoier

@helloworldstone Yea it's likely related to Vulkan driver shipped in Harmony OS. We've also seen some issues with HarmonyOS so we only tested on android OS for Huawei phones...

ailzhang avatar Aug 29 '22 09:08 ailzhang

@helloworldstone is support on harmonyOS a hard requirement for your use case? If so please let us know!

ailzhang avatar Aug 29 '22 09:08 ailzhang

Thank you @ailzhang ! HarmonyOS is a hard requirement. Because our algorithm will run on a wide range of android phones. In addition,this will limit taichi aot promotion severely,because almost all apps don't distinguish android OS or harmonyOS for Huawei phones.

helloworldstone avatar Aug 29 '22 12:08 helloworldstone

@helloworldstone do you happen to have the logs on harmonyos when validation layer is enabled? Thanks! Here's what we used to do for android but not sure if it's working on HarmonyOS.

  • https://github.com/taichi-dev/taichi/blob/master/taichi/rhi/vulkan/vulkan_device_creator.cpp#L21
  • https://developer.android.com/ndk/guides/graphics/validation-layer

p.s. mobile device coverage is kinda a hard problem with different combos of (android api version, snapdragon/mali chips, mobile phone vendors) so we had to de-prioritize HarmonyOS when we produce the initial prototypes. But we're definitely open to discussion and happy to learn about your use case. If you'd like a sync offline, feel free to send us an email via [email protected]!

ailzhang avatar Aug 30 '22 04:08 ailzhang