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

vulkaninfo can not run if VulkanSDK is not installed #1063

Open
FlyAndNotDown opened this issue Dec 29, 2024 · 2 comments
Open

vulkaninfo can not run if VulkanSDK is not installed #1063

FlyAndNotDown opened this issue Dec 29, 2024 · 2 comments

Comments

@FlyAndNotDown
Copy link

FlyAndNotDown commented Dec 29, 2024

If macOS VulkanSDK 1.3.296 is used with on installed, run vulkaninfo and you will get this:

ERROR at /Users/lunarg/Dev/macos-sdk-build/Vulkan-Tools/vulkaninfo/./vulkaninfo.h:409: Failed to initialize: Vulkan loader is not installed, not found, or failed to load.

I always use VulkanSDK with no installed and config icd.d/explicit_layer.d manually in /home/me/.config/vulkan and in early version of VulkanSDK it worked.

I checked source code of vulkaninfo, and I found this:

// 1.3.268
VkResult dllErr = dll.Initialize();
if (dllErr != VK_SUCCESS) {
    THROW_ERR("Failed to initialize: Vulkan loader is not installed, not found, or failed to load.");
}

// 1.3.296
VkResult dllErr = volkInitialize();

if (dllErr != VK_SUCCESS) {
    THROW_ERR("Failed to initialize: " API_NAME " loader is not installed, not found, or failed to load.");
}

New version will use volk to perform vulkan library load. And volk initialize do this:

VkResult volkInitialize(void)
{
#if defined(_WIN32)
	HMODULE module = LoadLibraryA("vulkan-1.dll");
	if (!module)
		return VK_ERROR_INITIALIZATION_FAILED;

	// note: function pointer is cast through void function pointer to silence cast-function-type warning on gcc8
	vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)(void(*)(void))GetProcAddress(module, "vkGetInstanceProcAddr");
#elif defined(__APPLE__)
	void* module = dlopen("libvulkan.dylib", RTLD_NOW | RTLD_LOCAL);
	if (!module)
		module = dlopen("libvulkan.1.dylib", RTLD_NOW | RTLD_LOCAL);
	if (!module)
		module = dlopen("libMoltenVK.dylib", RTLD_NOW | RTLD_LOCAL);
    // Add support for using Vulkan and MoltenVK in a Framework. App store rules for iOS
    // strictly enforce no .dylib's. If they aren't found it just falls through
    if (!module)
        module = dlopen("vulkan.framework/vulkan", RTLD_NOW | RTLD_LOCAL);
    if (!module)
        module = dlopen("MoltenVK.framework/MoltenVK", RTLD_NOW | RTLD_LOCAL);
	// modern versions of macOS don't search /usr/local/lib automatically contrary to what man dlopen says
	// Vulkan SDK uses this as the system-wide installation location, so we're going to fallback to this if all else fails
	if (!module && getenv("DYLD_FALLBACK_LIBRARY_PATH") == NULL)
		module = dlopen("/usr/local/lib/libvulkan.dylib", RTLD_NOW | RTLD_LOCAL);
	if (!module)
		return VK_ERROR_INITIALIZATION_FAILED;

	vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)dlsym(module, "vkGetInstanceProcAddr");
#else
	void* module = dlopen("libvulkan.so.1", RTLD_NOW | RTLD_LOCAL);
	if (!module)
		module = dlopen("libvulkan.so", RTLD_NOW | RTLD_LOCAL);
	if (!module)
		return VK_ERROR_INITIALIZATION_FAILED;
	VOLK_DISABLE_GCC_PEDANTIC_WARNINGS
	vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)dlsym(module, "vkGetInstanceProcAddr");
	VOLK_RESTORE_GCC_PEDANTIC_WARNINGS
#endif

	loadedModule = module;
	volkGenLoadLoader(NULL, vkGetInstanceProcAddrStub);

	return VK_SUCCESS;
}

It just load vulkan dynamic library in system or in working directory, it will break vulkaninfo application when VulkanSDK is not installed.

In my workflow, there is a simple workaround: just copy libvulkan.dylib to same directory of vulkaninfo application or just set working directory of vulkaninfo application to path of libvulkan.dylib.

But you know some projects will pack all the VulkanSDK as 3rd party dependency, in this way, VulkanSDK will not installed, so I want to report this, I think vulkaninfo need to give same experience no matter VulkanSDK installed or not. Cause it is a important tool to diagnose vulkan environment.

@FlyAndNotDown FlyAndNotDown changed the title vulkaninfo vulkaninfo can not run if VulkanSDK is not installed Dec 29, 2024
@charles-lunarg
Copy link
Contributor

I believe this is a regression in vulkaninfo and has been fixed by 0f30717

We are working on a new SDK which will contain that commit, so the fix should be out shortly (within a week or two). I'll try to post here when that occurs so you can try out the SDK with the commit to see if its fixed.

@FlyAndNotDown
Copy link
Author

Ok, thanks for your work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants