Merge remote-tracking branch 'upstream/master' into yoda-wayland-only
# Conflicts: # Cargo.lock # Cargo.toml # wgpu/Cargo.toml # wgpu/src/window/compositor.rs
This commit is contained in:
commit
d24bcd0272
36 changed files with 475 additions and 209 deletions
|
|
@ -30,6 +30,7 @@ strict-assertions = []
|
|||
# builds just leave this off — window/x11.rs and the DRI3 device-id
|
||||
# fallback in window/compositor.rs are cfg-gated on it.
|
||||
x11 = ["dep:as-raw-xcb-connection", "dep:tiny-xlib", "dep:x11rb"]
|
||||
wayland = ["cctk"]
|
||||
|
||||
[dependencies]
|
||||
iced_debug.workspace = true
|
||||
|
|
@ -70,3 +71,6 @@ x11rb = { version = "0.13.1", optional = true, features = [
|
|||
"dri3",
|
||||
"randr",
|
||||
] }
|
||||
|
||||
[build-dependencies]
|
||||
build_helpers = { path = "../build_helpers" }
|
||||
|
|
|
|||
3
wgpu/build.rs
Normal file
3
wgpu/build.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
build_helpers::cfg_aliases_setup();
|
||||
}
|
||||
|
|
@ -1,11 +1,6 @@
|
|||
//! Display rendering results on windows.
|
||||
pub mod compositor;
|
||||
#[cfg(all(
|
||||
unix,
|
||||
feature = "cctk",
|
||||
not(target_os = "macos"),
|
||||
not(target_os = "redox")
|
||||
))]
|
||||
#[cfg(wayland_platform)]
|
||||
mod wayland;
|
||||
#[cfg(all(unix, feature = "x11", not(target_os = "macos"), not(target_os = "redox")))]
|
||||
mod x11;
|
||||
|
|
|
|||
|
|
@ -9,16 +9,10 @@ use crate::graphics::{self, Shell, Viewport};
|
|||
use crate::settings::{self, Settings};
|
||||
use crate::{Engine, Renderer};
|
||||
|
||||
#[cfg(all(
|
||||
unix,
|
||||
feature = "cctk",
|
||||
not(target_os = "macos"),
|
||||
not(target_os = "redox")
|
||||
))]
|
||||
#[cfg(wayland_platform)]
|
||||
use super::wayland::get_wayland_device_ids;
|
||||
#[cfg(all(unix, feature = "x11", not(target_os = "macos"), not(target_os = "redox")))]
|
||||
use super::x11::get_x11_device_ids;
|
||||
use std::future::Future;
|
||||
|
||||
/// A window graphics backend for iced powered by `wgpu`.
|
||||
pub struct Compositor {
|
||||
|
|
@ -65,12 +59,7 @@ impl Compositor {
|
|||
compatible_window: Option<W>,
|
||||
shell: Shell,
|
||||
) -> Result<Self, Error> {
|
||||
#[cfg(all(
|
||||
unix,
|
||||
feature = "cctk",
|
||||
not(target_os = "macos"),
|
||||
not(target_os = "redox")
|
||||
))]
|
||||
#[cfg(wayland_platform)]
|
||||
let ids = compatible_window.as_ref().and_then(|window| {
|
||||
let w = get_wayland_device_ids(window);
|
||||
#[cfg(feature = "x11")]
|
||||
|
|
@ -78,23 +67,13 @@ impl Compositor {
|
|||
w
|
||||
});
|
||||
|
||||
#[cfg(all(
|
||||
unix,
|
||||
not(feature = "cctk"),
|
||||
not(target_os = "macos"),
|
||||
not(target_os = "redox")
|
||||
))]
|
||||
let ids = compatible_window
|
||||
.as_ref()
|
||||
.and_then(|window| get_x11_device_ids(window));
|
||||
|
||||
// HACK:
|
||||
// 1. If we specifically didn't select an nvidia gpu
|
||||
// 2. and the user didn't specifically request an nvidia gpu
|
||||
// 3. and the user didn't set an adapter name,
|
||||
// 4. and the user didn't request the high power pref
|
||||
// => don't load the nvidia icd, as it might power on the gpu in hybrid setups causing severe delays
|
||||
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "redox")))]
|
||||
#[cfg(wayland_platform)]
|
||||
if !matches!(ids, Some((0x10de, _)))
|
||||
&& std::env::var_os("__NV_PRIME_RENDER_OFFLOAD")
|
||||
.is_none_or(|var| var == "0")
|
||||
|
|
@ -154,11 +133,7 @@ impl Compositor {
|
|||
let mut adapter = None;
|
||||
#[cfg_attr(not(unix), allow(dead_code))]
|
||||
if std::env::var_os("WGPU_ADAPTER_NAME").is_none() {
|
||||
#[cfg(all(
|
||||
unix,
|
||||
not(target_os = "macos"),
|
||||
not(target_os = "redox")
|
||||
))]
|
||||
#[cfg(wayland_platform)]
|
||||
if let Some((vendor_id, device_id)) = ids {
|
||||
adapter = instance
|
||||
.enumerate_adapters(settings.backends)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
#![allow(unexpected_cfgs)]
|
||||
|
||||
use std::{
|
||||
fs,
|
||||
io::{BufRead, BufReader},
|
||||
|
|
@ -144,7 +146,9 @@ pub fn get_x11_device_ids<W: Window>(window: &W) -> Option<(u16, u16)> {
|
|||
{
|
||||
let stat =
|
||||
stat(Path::new("/dev/dri").join(device)).ok()?;
|
||||
let dev = stat.st_rdev;
|
||||
// Hack (u64 as u64) for E2K CPU architecture
|
||||
#[allow(clippy::unnecessary_cast)]
|
||||
let dev = stat.st_rdev as u64;
|
||||
return super::ids_from_dev(dev);
|
||||
}
|
||||
}
|
||||
|
|
@ -165,7 +169,9 @@ pub fn get_x11_device_ids<W: Window>(window: &W) -> Option<(u16, u16)> {
|
|||
let dri3 = conn.dri3_open(root, x11rb::NONE).ok()?.reply().ok()?;
|
||||
let device_fd = dri3.device_fd;
|
||||
let stat = fstat(device_fd).ok()?;
|
||||
let dev = stat.st_rdev;
|
||||
// Hack (u64 as u64) for E2K CPU architecture
|
||||
#[allow(clippy::unnecessary_cast)]
|
||||
let dev = stat.st_rdev as u64;
|
||||
super::ids_from_dev(dev)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue