zeux/volk

question on unloading the dll

lch32111 opened this issue · 4 comments

Thank you for sharing this simple loader.

I'd like to know why there is no a corresponding function to the volkInitialize to unload the loaded dll.
I know it's just simple to add that function and unload the dll by myself. But I just wanted to know your opinion about not adding it.

Thanks!

there is a workaround if you're using SDL, SFML or GLFW which is to use volkInitializeCustom instead passing it the function vkGetInstanceProcAddr from one of those librairies on any library that would allow you load vulkan yourself
Tho I personally never use volkInitialize, unless if am making a compute only application where I don't have SDL or similar

On SDL, that would be:

    SDL_Vulkan_LoadLibrary(NULL);
    volkInitializeCustom((PFN_vkGetInstanceProcAddr) SDL_Vulkan_GetVkGetInstanceProcAddr());
    // Volk is initialized...
    SDL_Vulkan_UnloadLibrary();

yeah I know what you mean. I can load the dll by myself LoadLibraryA or dlopen and then pass my own function pointer to the volkInitializeCustom where I call the vkGetInstanceProcAddr for the dll.

It's not a serious thing, but I am just simply asking the question in the perspective of the API design. If a user calls the volkInitialize, then there is no way to unload the dll except closing the application which calls the volkInitialize. As I mentioned simply before, I can add the function volkFinailize that unloads the dll by saving the module variable in the volkInitialize to a static variable. (Actually I did it on my code base)

zeux commented

It just never came up before. I'll look into adding a finalize function.