Expand description
Graphics and compute API versions: Vulkan, OpenGL and OpenCL.
The last user-visible gap against fastfetch (NOTES.md §6). Each API is reached by
dlopening its loader at runtime rather than linking it, for three reasons:
- Linking would make the libraries hard requirements. A machine without Vulkan
must still run retch; a
#[link]onlibvulkanwould refuse to start. - They are genuinely optional. Absence is a normal answer (“no Vulkan here”), not an error, so the field is simply omitted.
- It keeps the crate free of new dependencies, matching the hand-written FFI house style used for the Windows and macOS probes.
§These probes never modify the process environment
Mesa’s rusticl OpenCL driver is opt-in via RUSTICL_ENABLE: without it the ICD
still registers a platform advertising OpenCL 3.0 while exposing zero devices.
It is tempting to set that variable in-process before loading the ICD so the field
looks better. This module deliberately does not, for two reasons:
- It would be a data race. Fields are collected inside a
std::thread::scope, and mutating the environment while sibling threads read it is unsound.std::env::set_varbecameunsafein Rust 2024 precisely for this; this crate is on edition 2021, where it still compiles silently — a trap rather than a compile error. - It would report something false. A device visible only because retch enabled it for itself is not a device the user’s own programs can use.
So the OpenCL field reports the device count it actually observes, and says when that
count is zero. fastfetch prints a bare OpenCL: 3.0 in both states — i.e. it reports a
working stack when nothing can run on it. Under-reporting beats asserting something
false, the same call as the Users: 0 suppression (v0.6.1) and the v0.7.0 input
classification.
Structs§
- GpuApis
- Versions reported by each graphics/compute API present on the system.
Functions§
- cstr_
field - Trim a NUL-terminated fixed-size C string field into a
String. - detect_
gpu_ apis - Detect Vulkan, OpenGL and OpenCL versions.
- device_
type_ rank - Rank a Vulkan
VkPhysicalDeviceTypeso the most capable real device wins. - format_
opencl - Render the OpenCL field, distinguishing “usable” from “present but inert”.
- format_
vulkan - Render the Vulkan field from its parts.
- format_
vulkan_ version - Decode a packed Vulkan version into
major.minor.patch. - shorten_
device_ name - Shorten a driver-reported device name to the part a human recognises.