Skip to content

Rewrite in Rust

Neil Roberts requested to merge nroberts/vkrunner:rust into main

This MR is based on the old one in Github here.

The MR replaces all of the C code with Rust, as mentioned in this message to the mesa-dev mailing list.

The Rust port should be a drop-in replacement for the C version so everything should continue to work as before. The static library with the API is also still generated so it should still work, although presumably nothing is using that since CTS dropped VkRunner. I’ve tested building on Android and Windows (well, with MinGW+Wine) and that should still work too.

This MR switches the build system from CMake to Meson. I think the Jenkins CI will try to automatically get the latest version from git and build with CMake. So if the MR is merged then the CI will need to be updated.

I haven’t tried to clean up the commits too much so there are a couple of patches where I’ve implemented something and then later changed how it works or fixed a mistake. Not sure if it’d be worth trying to squash some of them. However, I tried to make sure that it always builds so all of the commits should still work if anyone ends up bisecting in them.

The advantages of merging this PR are:

  • Going forward if someone works on VkRunner then it’s much nicer to write in Rust, particularly for doing string manipulation and not having to worry so much about cleaning up resources on errors.
  • I’ve added a lot of unit tests so the Rust version is potentially more robust.
  • I added a patch to make VkRunner pass --quiet to glslangvalidator and spirv-as so it no longer does the annoying thing of printing the temporary filenames when running.
  • I updated the test-build.sh script to use the right environment variable for the Vulkan validation layers. This picked up a problem with specifying the VkImageAspectFlags when clearing the depth buffer which wasn’t being picked up before. I’ve fixed that too.

The disadvantages are:

  • Fewer people know Rust.
  • It might break Jenkins.

Open questions:

  • Should we use Cargo instead of Meson? Generally anything written in Rust not using Cargo is an uphill struggle.
  • Should we bundle the Vulkan headers in the repo? Currently the build needs the exact location of the Vulkan headers to run bindgen and it makes the build a bit awkward.

Merge request reports