Skip to content

google/vk-layer-for-rust

Vulkan Layer for Rust

postsubmit postsubmit miri Linux coverage Windows coverage Linux doc Windows doc

This project provides a way to use safe Rust to write a Vulkan layer.

Contributing

See CONTRIBUTING.md for details.

License

Apache 2.0; see LICENSE for details.

Disclaimer

This project is not an official Google project. It is not supported by Google and Google specifically disclaims all warranties as to its quality, merchantability, or fitness for a particular purpose.

Build

cross-compile from Windows to Android

  1. Install the Rust Android toolchain

    rustup target add x86_64-linux-android
  2. Set up the linker to use. Add the following lines to the config.toml file. I will just use %CARGO_HOME%/config.toml.

    [target.x86_64-linux-android]
    linker = "%NDK_HOME%\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\x86_64-linux-android33-clang"
    

    Note that %NDK_HOME% must be expanded to an explicit absolute path, which is usually %LOCALAPPDATA%/Android/Sdk/ndk/<version-number>.

  3. If the NDK version is greater than 22, follow this workaround.

  4. cargo build --target x86_64-linux-android.

Windows natively

cargo build

Soong in an Android tree

TODO

TODO

  • Set up Android.bp to build in an Android tree.
    • Upgrade ash in aosp, and remove vulkano, so that we can build from aosp/master.
  • Auto-generate the binding from vk_layer.h.
  • Auto-generate the Layer trait and the interception code from vk.xml.
  • Use an attribute macro to track which function is implemented in the Layer trait, and don't inject all other functions for performance.
  • Make global instance trivially destructible after all instances are destroyed, so the layer is robust against the situation where the dynamic library is loaded and unloaded for several times.
  • Use procedure macro to generate the export functions in lib.rs file for the layer user.
  • Use the xtask workflow to generate the layer json file.
  • Support the latest layer interface version. Currently 2 is the latest version. e.g. correctly handle the vk_layerGetPhysicalDeviceProcAddr case.
  • Allow intercepting pre-instance functions.
  • Add docstring to generated layer_trait.rs file.
  • Testing
    • e2e test: the test boundary is the Vulkan layer ABI. The Vulkan loader and the mock ICD will be used for testing. Write a cdylib crate named tests, with a layer that is allowed to customize the behavior through a function exported as a dynamic library symbol. We run different tests in different processes. For different tests, we customize the layer differently, and asserts either inside the customization point or after it returns, e.g. to test initialization and destruction on DLL loading and unloading time, we can customize the ctor and the drop implementation for the layer, then load and unload the Vulkan library then verify if the ctor is called the same time as the drop. We also need to create a e2e task to build the DLL, generate the json, set the environement variables, and spawn tests in different processes(cargo-nextest can be used here since it runs tests in their own process).
    • vulkan-layer level integration test
  • catch unwind at the FFI boundary to allow the library to be compiled with panic="unwind".
  • Imporve Miri test
    • Check why fp comparison in miri fails in test_should_move_layer_device_link_forward, test_should_move_layer_device_link_forward, and test_should_return_fp_for_get_instance_proc_addr.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published