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

Add Instance::with_loading_function for better cross-platform handling #361

Closed
tomaka opened this issue Jan 23, 2017 · 1 comment
Closed

Comments

@tomaka
Copy link
Member

tomaka commented Jan 23, 2017

Right now the Vulkan library is loaded in the loader module. Depending on the operating system the path to the library is different.

When trying to add support for MoltenVK, this became a problem because MoltenVK is a static library that must be linked at compile-time. PR #301 tweaks the loader module to have a totally different behavior on OSX.

However it would be great to not rely on any platform-specific behavior, in case the user wants to use a custom way of accessing Vulkan. Therefore I suggest adding Instance::with_loading_function:

impl Instance {
    pub unsafe fn with_loading_function(f: *const c_void, ... other params ...) -> Result<Instance, ...> {
        ...
    }
}

The function f passed to with_loading_function must be the implementation vkGetInstanceProcAddr, and will be used by vulkano to load everything.

The Instance::new function would be modified to use Instance::with_loading_function under the hood.

With this change Instance::new would try to work transparently on all major platforms, but the user could choose a custom implementation/behavior.

@tomaka
Copy link
Member Author

tomaka commented Jan 25, 2017

Unfortunately what I didn't think about is that getting the list of layers and extensions also requires loading the function pointers.
Therefore we will need some sort of intermediate object I think.

Example:

let vk_library = unsafe { LoadedLibrary::from_function(...) };
let layers = vk_library.layers_supported_by_core();
let instance = Instance::with_library(vk_library).unwrap();

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

No branches or pull requests

1 participant