Skip to main content

gpu_preference_from_env

Function gpu_preference_from_env 

Source
pub fn gpu_preference_from_env() -> Option<GpuPreference>
Expand description

The debug GPU override as a GpuPreference, for the headless entry point that has no platform instance to ask.

ZED_DEVICE_ID is read here, in the platform, so neither the renderer nor gpui_platform knows the variable. A windowed application reaches the same value through set_gpu_preference; the headless renderer has no platform, so gpui::current_headless_renderer calls this instead. The debug GPU override, for the headless entry point that has no platform instance. The debug override, lowered to a GpuPreference::Device.

It lives here, not in the renderer or the shared platform crate, because a debug variable is an OS-integration detail: the one path the renderer sees is set_gpu_preference, which an application’s stated preference also takes. The headless entry point has no platform instance to ask, so it calls this directly. A malformed value is logged and ignored rather than silently falling through to a different GPU.