google / shaderc-rs

Rust bindings for the shaderc library.
https://docs.rs/shaderc
Apache License 2.0
261 stars 64 forks source link

Check vulkan sdk version #121

Closed msklywenn closed 2 years ago

msklywenn commented 2 years ago

A while back, I got a peculiarly cryptic error like this one: Running rustc --crate-name vulkano_test [... very long arguments ...] undefined symbol: shaderc_compile_options_set_auto_combined_image_sampler

It took me a while to figure out that this was a function in shaderc and that it was showing up just because the Vulkan SDK I had installed on my machine a while back was too old now. When I looked it up, I found several people with the same issue and with various solutions (often going back to an older version of shaderc-rs assuming it was a bug in it). It happened today again to someone.

This PR adds a check for the version of the vulkan SDK that shaderc-rs is trying to build from. I set the minimal version to 1.2.182.0 as it seems from my research that it is the version that introduced the missing function. But I am not actually exactly sure if a version even more recent is needed or not.

Rua commented 2 years ago

How is the progress on this work? I ran into this issue myself with Vulkano, and since then several others have encountered it as well.

antiagainst commented 2 years ago

This is a nice feature to have, thanks @msklywenn!

Broadly it's hard to inspect the installed shaderc system library's version, given there are so many ways they can exist in a system (installed via LunarG apt package, installed via downloading the tarball from LunarG, installed via manually compiling a specific version of shaderc, etc.). Inspecting the SDK version under $VULKAN_SDK is actually a loose way to check it. It works for the case that he whole SDK is downloaded from LunarG as a tarball. I guess the only reliable way is to load the library and try to get the symbol out of it. Not for now though. Having coverage for this is already a great step!

Minimal requirement of 1.2.182.0 sounds right to me. shaderc_compile_options_set_auto_combined_image_sampler was introduced in https://github.com/google/shaderc/commit/620ee651a7ae4b18cd4a960eb36cfb2f11799f8d on May 10, 2021. SDK 1.2.182.0 released on July 5, 2021 and contains it. The previous release, 1.2.176.1, was on May 5, 2021.

antiagainst commented 2 years ago

hmm, actually, I cannot find the "components.xml" file in Vulkan SDK installed on Linux. We can also check the "vk.xml" file for such information I think.

antiagainst commented 2 years ago

Cherry picked the change into https://github.com/google/shaderc-rs/pull/123 and trying out there..