ash icon indicating copy to clipboard operation
ash copied to clipboard

Unable to find a Vulkan driver.

Open t-gazzy opened this issue 1 year ago • 4 comments

Hello. I have the problem that the Instance is not created by create_instance with Unable to find a Vulkan driver message. Do you have any idea to fix?

env

  • ash = {version = "0.37.3", features=["linked"]}
  • MacOS: 14.3
  • VulkanSDK: 1.3.268.0 (installed from LunarG)

paths

export VULKAN_SDK=$HOME/VulkanSDK/1.3.268.1/macOS
export PATH=$VULKAN_SDK/bin:$PATH
export DYLD_LIBRARY_PATH=$VULKAN_SDK/lib:$DYLD_LIBRARY_PATH
export VK_ICD_FILENAMES=$VULKAN_SDK/share/vulkan/icd.d/MoltenVK_icd.json
export VK_LAYER_PATH=$VULKAN_SDK/share/vulkan/explicit_layer.d

sample code

fn main() {
  let entry = Entry::linked();
  let app_info = vk::ApplicationInfo {
      api_version: vk::make_api_version(0, 1, 2, 0),
      ..Default::default()
  };
  let create_info = vk::InstanceCreateInfo {
      p_application_info: &app_info,
      ..Default::default()
  };
  let instance = match unsafe { entry.create_instance(&create_info, None) } {
      Ok(instance) => instance,
      Err(e) => panic!("failed to create instance. :{}", e),
      // this panic occurs. 
      // `thread 'main' panicked at 'failed to create instance. :Unable to find a Vulkan driver`
  };
}

t-gazzy avatar Feb 15 '24 12:02 t-gazzy

If you want to statically link on macOS, you may want to take a look at https://github.com/embarkstudios/ash-molten. Otherwise, using Entry::load should also work.

Friz64 avatar Feb 15 '24 12:02 Friz64

thank you for your quick response. i used features=["loaded"] and Entry.load() instead, still same error occurs. cache clear and rebuild did not make it work. it looks like Entry::load works.

[dependencies]
ash = {version = "0.37.3", features=["loaded"]}
let entry = match unsafe { Entry::load() } {
    Ok(entry) => {
        println!("load OK"); // <= this is shown in the console
        entry
    },
    Err(e) => panic!("load failed: {}", e),
};
// same code...

t-gazzy avatar Feb 15 '24 14:02 t-gazzy

I don't know much about macOS, maybe this StackOverflow post has something useful in it? https://stackoverflow.com/questions/58732459/vk-error-incompatible-driver-with-mac-os-and-vulkan-moltenvk

Friz64 avatar Feb 16 '24 07:02 Friz64

I have tried so many times, I realized that probably the execute command was wrong. cargo run => failed(unable to find vulkan driver) cargo run --package {package_name} --bin {bin_name}=> succeeded

this bug may not be related. sorry.

t-gazzy avatar Feb 22 '24 15:02 t-gazzy