-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix OpenBSD compilation of wgpu_hal::vulkan::drm
#7810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,15 @@ use core::mem::MaybeUninit; | |
|
||
use ash::{ext, khr, vk}; | ||
|
||
macro_rules! to_u64 { | ||
($expr:expr) => {{ | ||
#[allow(trivial_numeric_casts)] | ||
let expr = $expr as u64; | ||
assert!(size_of_val(&expr) <= size_of::<u64>()); | ||
expr | ||
}}; | ||
} | ||
Comment on lines
+8
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like to take this opportunity to express my distaste for the lack of portability motivating this workaround, and the workaround itself. 😫 Otherwise, thanks in advance for reviewing~! |
||
|
||
impl super::Instance { | ||
/// Creates a new surface from the given drm configuration. | ||
/// | ||
|
@@ -77,12 +86,18 @@ impl super::Instance { | |
let render_devid = | ||
libc::makedev(drm_props.render_major as _, drm_props.render_minor as _); | ||
|
||
// Various platforms use different widths between `dev_t` and `c_int`, so just | ||
// force-convert to `u64` to keep things portable. | ||
// On most platforms, both `*_devid`s and `st_rdev` are `dev_t`s (which is generally | ||
// observed to be an unsigned integral type no greater than 64 bits). However, on some | ||
// platforms, there divergences from this pattern: | ||
// | ||
// - `armv7-linux-androideabi`: `dev_t` is `c_ulong`, and `*_devid`s are `dev_t`, but | ||
// `st_rdev` is `c_ulonglong`. So, we can't just do a `==` comparison. | ||
// - OpenBSD has `dev_t` on both sides, but is unsigned. Therefore, we can't just use | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unsigned, and on 32-bits according to @semarie (our resident rust expert) |
||
// `u64::from`. | ||
#[allow(clippy::useless_conversion)] | ||
if [primary_devid, render_devid] | ||
.map(u64::from) | ||
.contains(&drm_stat.st_rdev) | ||
.map(|devid| to_u64!(devid)) | ||
.contains(&to_u64!(drm_stat.st_rdev)) | ||
{ | ||
physical_device = Some(device) | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.