This rewrites all of the Python scripts that generate code in Rust and makes them part of the Cargo build script. Previously the Python scripts had to be run by hand and the output was checked in to the repo.
Now that the Vulkan headers are checked into the repo thanks to MR#4 it’s easier to run the code generation as part of the build because we’ll always be using a known working version of the Vulkan headers. In the MR I’ve also made it so that the Vulkan headers are scanned by adding callbacks to bindgen instead of searching using regular expressions over the header files. This should probably make it a lot more robust. Generating the code as part of the build process makes sure that the scripts never break because whoever changes the Vulkan headers will end up having to do the code generation too.
Unfortunately this adds quite a lot of build-time dependencies in order to use the Tera template engine. I’ve checked that the versions required work with those in Debian testing in order to avoid breaking the CI.
Neil Roberts (ca09ccd8) at 29 Oct 15:11
Generate pipeline_key_data.rs in the build script
... and 9 more commits
Neil Roberts (93cbb7b1) at 29 Oct 15:05
As discussed in a comment for the MR to rewrite the project in Rust, this MR switches to Cargo instead of Meson and bundles the Vulkan headers in the repo so that we don’t have to have the awkward build option to find them and we can be sure to have a known working version. I guess this doing two unrelated things in one merge request, but if we made separate MRs then they would conflict with each other and it would be a bit annoying.
The Vulkan headers are version 1.3.266.
The bindgen phase is now run using the Cargo build script instead of using bindgen-cli.
The fake_compiler
test executable has been replaced with a stub fake_command module that replaces std::process::Command
in the test config. I couldn’t find a way to get Cargo to build an executable that is only used by the unit tests and isn’t installed.
The README recommends to use cargo-c to install the static C library and headers.
The build-wind32.sh
script has been removed because cross-compiling with Cargo is quite easy and the script probably isn’t necessary. You just need to install the right toolchain with rustup and then pass --target
to cargo build. However the windows build is currently broken because of issue #1 anyway.
This was motivated by the tests tripping up when running in parallel
(the default for cargo test
). The tests failed intermittently
in the following scenario:
two_files
test would create a tempfile then remove a temporary file;read
test would create a tempfile and able to pick the same name;two_files
would check if the file was not there anymore, but it was!Isolating the two_files
test with its own prefix fixes the issue.
Neil Roberts (3eea632d) at 29 Oct 14:57
Add a way to provide a prefix to TempFile
Neil Roberts (3eea632d) at 29 Oct 14:56
Add a way to provide a prefix to TempFile
This was motivated by the tests tripping up when running in parallel
(the default for cargo test
). The tests failed intermittently
in the following scenario:
two_files
test would create a tempfile then remove a temporary file;read
test would create a tempfile and able to pick the same name;two_files
would check if the file was not there anymore, but it was!Isolating the two_files
test with its own prefix fixes the issue.
Neil Roberts (f12eb8ba) at 07 Oct 08:20
vkrunner: Explicitly call drop() when freeing Box resources
... and 1 more commit
The NaN is a real fix, the other just make the code clearer (and silence the warning). Details in the commit messages.
Neil Roberts (420f2f86) at 06 Oct 10:40
Generate pipeline_key_data.rs in the build script
... and 5 more commits
Thanks for looking into this. Yes, I’m happy to downgrade the version requirement so I’ve updated the branch to use bindgen 0.66.1. Is building offline a requirement for the Intel CI? The code-generation-during-build
adds some extra build dependencies as well so I’ve updated that to use the versions available in Debian testing and it seems to work.
Neil Roberts (3efbc6a3) at 06 Oct 10:26
Use Cargo instead of Meson
For what it’s worth, I’ve made a separate branch on top of this merge request that rewrites all of the Python scripts that generate code in Rust and makes them part of the Cargo build script. Previously the Python scripts had to be run by hand and the output was checked in to the repo. If this MR lands then it’s easier to run the code generation as part of the build because we’ll always be using a known working version of the Vulkan headers. In the branch I’ve also made it so that the Vulkan headers are scanned by adding callbacks to bindgen instead of searching using regular expressions over the header files. This should probably make it a lot more robust. Generating the code as part of the build process makes sure that the scripts never break because whoever changes the Vulkan headers will end up having to do the code generation too. I think this is quite a nice advantage of bundling the Vulkan headers and using Cargo. If this MR to switch to Cargo lands I’ll file that branch as a separate MR.
Neil Roberts (65d73040) at 05 Oct 14:48
Generate pipeline_key_data.rs in the build script
... and 247 more commits
As discussed in a comment for the MR to rewrite the project in Rust, this MR switches to Cargo instead of Meson and bundles the Vulkan headers in the repo so that we don’t have to have the awkward build option to find them and we can be sure to have a known working version. I guess this doing two unrelated things in one merge request, but if we made separate MRs then they would conflict with each other and it would be a bit annoying.
The Vulkan headers are version 1.3.266.
The bindgen phase is now run using the Cargo build script instead of using bindgen-cli.
The fake_compiler
test executable has been replaced with a stub fake_command module that replaces std::process::Command
in the test config. I couldn’t find a way to get Cargo to build an executable that is only used by the unit tests and isn’t installed.
The README recommends to use cargo-c to install the static C library and headers.
The build-wind32.sh
script has been removed because cross-compiling with Cargo is quite easy and the script probably isn’t necessary. You just need to install the right toolchain with rustup and then pass --target
to cargo build. However the windows build is currently broken because of issue #1 anyway.
Building on Windows seems to fail because bindgen uses the i32
for the constants generated from enums whereas on Linux they as u32
. Presumably on Windows the default type for enums is signed? As far as I understand that is a compiler decision.
This is difficult to fix because the Vulkan headers use a mix of enums for the bit values and u32 types for the combined type. For example VkImageAspectFlags
is defined to be VkFlags
which is explicitly always a uint32_t
. But the actual members that you are supposed to fill that type with are VkImageAspectFlagBits
which is an enum and will therefore be int
on Windows. Then in rust if you try to return VK_IMAGE_ASPECT_COLOR_BIT
from a function that has a return type of VkImageAspectFlags
it will complain about the implicit sign conversion.
Maybe the solution is to fill the code with ugly explicit casts.