Skip to content

Commit 02981af

Browse files
committed
[hal] Make DRM support optional.
In `wgpu_hal`, make support for `RawWindowHandle::Drm` and `RawDisplayHandle::Drm` require that the `"drm"` feature be explicitly requested, rather than supporting DRM handles by default. The DRM API is for interacting with GPUs and displays directly via system calls, without going through something like Mesa. Very few `wgpu` users are driving hardware directly, and those that are are sophisticated users, capable of finding and requesting the feature themselves. Supporting DRM in `wgpu_hal` adds dependencies on `drm` and its supporting crates. The crates seem fine, but they do contribute to download and build time. Firefox definitely does not want to have to vendor `drm` and its subcrates into its source tree, since Firefox should never be interacting with graphics hardware directly.
1 parent 9c49f92 commit 02981af

3 files changed

Lines changed: 3 additions & 8 deletions

File tree

wgpu-hal/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ vulkan = [
9494
"dep:arrayvec",
9595
"dep:ash",
9696
"dep:bytemuck",
97-
"dep:drm",
9897
"dep:gpu-descriptor",
9998
"dep:hashbrown",
10099
"dep:libc",

wgpu-hal/src/vulkan/drm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![cfg(all(unix, not(target_vendor = "apple"), not(target_family = "wasm")))]
1+
#![cfg(feature = "drm")]
22

33
use alloc::{string::ToString, vec::Vec};
44
use core::{mem::MaybeUninit, num::NonZeroU32};

wgpu-hal/src/vulkan/instance.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,7 @@ impl super::Instance {
264264
extensions.push(ext::metal_surface::NAME);
265265
extensions.push(khr::portability_enumeration::NAME);
266266
}
267-
if cfg!(all(
268-
unix,
269-
not(target_vendor = "apple"),
270-
not(target_family = "wasm")
271-
)) {
267+
if cfg!(feature = "drm") {
272268
// VK_EXT_acquire_drm_display -> VK_EXT_direct_mode_display -> VK_KHR_display
273269
extensions.push(ext::acquire_drm_display::NAME);
274270
extensions.push(ext::direct_mode_display::NAME);
@@ -892,7 +888,7 @@ impl crate::Instance for super::Instance {
892888
let connection = display.connection.expect("Pointer to X-Server is not set.");
893889
self.create_surface_from_xcb(connection.as_ptr(), handle.window.get())
894890
}
895-
#[cfg(all(unix, not(target_vendor = "apple"), not(target_family = "wasm")))]
891+
#[cfg(feature="drm")]
896892
(Rwh::Drm(handle), Rdh::Drm(display)) => {
897893
self.create_surface_from_drm_plane(display.fd, handle.plane)
898894
}

0 commit comments

Comments
 (0)