KomputeProject / kompute

General purpose GPU compute framework built on Vulkan to support 1000s of cross vendor graphics cards (AMD, Qualcomm, NVIDIA & friends). Blazing fast, mobile-enabled, asynchronous and optimized for advanced GPU data processing usecases. Backed by the Linux Foundation.
http://kompute.cc/
Apache License 2.0
1.88k stars 145 forks source link

Manager: fix debug layers on Android #341

Open cebtenzzre opened 8 months ago

cebtenzzre commented 8 months ago

I haven't tested this on Android, but on a fork that always uses the dynamic symbol lookup, I ran into this compilation error:

/home/admin/src_clones/gpt4all/gpt4all-backend/llama.cpp-mainline/kompute/src/Manager.cpp:273:36: error: no matching function for call to ‘vk::DispatchLoaderDynamic::init(std::__shared_ptr_access<vk::Instance, __gnu_cxx::_S_atomic, false, false>::element_type&, void (* (**)(VkInstance, const char*))())’
  273 |         this->mDebugDispatcher.init(*this->mInstance, &vkGetInstanceProcAddr);
<snip>
/home/admin/src_clones/gpt4all/gpt4all-backend/build/_deps/vulkan_header-src/include/vulkan/vulkan.hpp:13180:42: note:   no known conversion for argument 2 from ‘void (* (**)(VkInstance, const char*))()’ {aka ‘void (* (**)(VkInstance_T*, const char*))()’} to ‘PFN_vkGetInstanceProcAddr’ {aka ‘void (* (*)(VkInstance_T*, const char*))()’}

It should be possible to reproduce if you build it like this:

$ cmake -B build -DKOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS=OFF -DKOMPUTE_OPT_ANDROID_BUILD=ON
$ make -C build
cebtenzzre commented 8 months ago

Actually this isn't enough, because it's crashing while trying to do vk::enumerateInstanceLayerProperties even though it hasn't initialized the dynamic loader yet.

axsaucedo commented 8 months ago

Thank you for submitting - would you be able to test it in the android example? The reason why i ask is because that uses a very particular version of the vulkan libraries for compatibility so it would need to be validated

cebtenzzre commented 7 months ago

would you be able to test it in the android example?

Sorry, I don't have the time to attempt something like that. Since the existing code doesn't compile with the latest regular Vulkan headers, I don't see how this PR could be worse. Unless there's some version of Vulkan where vk::DispatchLoaderDynamic::init takes a pointer to a pointer to a function?

axsaucedo commented 6 months ago

Thank you for the heads up - no worries, we'll have to test it before merging it, we'll test it on our side