From c9b43dcb7e9291f46211da7c0d2f143b7ada18cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Vasconcellos?= Date: Thu, 6 Jun 2024 02:05:28 -0300 Subject: [PATCH 01/10] Workaround nvidia on linux segfault --- Cargo.lock | 81 ++++++++++++++++++++++++++++ apps/desktop/crates/linux/Cargo.toml | 2 + apps/desktop/crates/linux/src/env.rs | 22 ++++++++ 3 files changed, 105 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 3ce9388a41ab..de5285e723b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1848,6 +1848,15 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +[[package]] +name = "cmake" +version = "0.1.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" +dependencies = [ + "cc", +] + [[package]] name = "cmov" version = "0.3.1" @@ -3758,6 +3767,70 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f924267408915fddcd558e3f37295cc7d6a3e50f8bd8b606cee0808c3915157e" +[[package]] +name = "gl" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a94edab108827d67608095e269cf862e60d920f144a5026d3dbcfd8b877fb404" +dependencies = [ + "gl_generator", +] + +[[package]] +name = "gl-headless" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2a15605d075e3ca0eb9840d9945ce21168c3f66c0422fa929e69b6bdf15a930" +dependencies = [ + "gl", + "gl-headless-macros", + "glfw", +] + +[[package]] +name = "gl-headless-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "912d61fc34c2002bfb42bbd3509f2dc7002534b23bb3f6f5bdade6de1317e60f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "gl_generator" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d" +dependencies = [ + "khronos_api", + "log", + "xml-rs", +] + +[[package]] +name = "glfw" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "919ebc7bdbf60a529689a5e58f80d9dcde27e3d2ab4f2f7ce711ec439fe789c5" +dependencies = [ + "bitflags 1.3.2", + "glfw-sys", + "objc", + "raw-window-handle 0.5.2", + "winapi", +] + +[[package]] +name = "glfw-sys" +version = "4.0.0+3.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5abed6d39a50226676aab893d6b4ad154da7e93fcdfed90d7696758a1b477ed1" +dependencies = [ + "cmake", +] + [[package]] name = "glib" version = "0.18.5" @@ -4880,6 +4953,12 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "khronos_api" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" + [[package]] name = "kqueue" version = "1.0.8" @@ -9344,6 +9423,8 @@ dependencies = [ name = "sd-desktop-linux" version = "0.1.0" dependencies = [ + "gl", + "gl-headless", "gtk", "libc", "tokio", diff --git a/apps/desktop/crates/linux/Cargo.toml b/apps/desktop/crates/linux/Cargo.toml index b61d10fc2c86..593540196eca 100644 --- a/apps/desktop/crates/linux/Cargo.toml +++ b/apps/desktop/crates/linux/Cargo.toml @@ -10,6 +10,8 @@ tokio = { workspace = true, features = ["fs"] } libc = { workspace = true } [target.'cfg(target_os = "linux")'.dependencies] +gl = "0.14" +gl-headless = "0.2" # WARNING: gtk should follow the same version used by tauri # https://github.com/tauri-apps/tauri/blob/tauri-v2.0.0-beta.17/core/tauri/Cargo.toml#L85C1-L85C51 gtk = { version = "0.18", features = [ "v3_24" ] } diff --git a/apps/desktop/crates/linux/src/env.rs b/apps/desktop/crates/linux/src/env.rs index b9bcc0ebabd2..ba7c8b9bc233 100644 --- a/apps/desktop/crates/linux/src/env.rs +++ b/apps/desktop/crates/linux/src/env.rs @@ -8,6 +8,8 @@ use std::{ ptr, }; +use gl_headless::gl_headless; + pub fn get_current_user_home() -> Option { use libc::{getpwuid_r, getuid, passwd, ERANGE}; @@ -175,6 +177,10 @@ pub fn normalize_environment() { ], ) .expect("PATH must be successfully normalized"); + + if is_nvidia() { + env::set_var("WEBKIT_DISABLE_DMABUF_RENDERER", "1"); + } } // Check if snap by looking if SNAP is set and not empty and that the SNAP directory exists @@ -198,3 +204,19 @@ pub fn is_flatpak() -> bool { false } + +// Check if system uses a nvidia card to render +#[gl_headless] +fn is_nvidia() -> String { + let Some(raw_vendor) = (unsafe { gl::GetString(gl::VENDOR).as_mut() }) else { + return false; + }; + let vendor = unsafe { + CStr::from_ptr(raw_vendor); + }; + return vendor + .to_str() + .unwrap_or("") + .to_lowercase() + .contains("nvidia"); +} From e0d6105164dc6b04a35abf85514ab95f8b8fc86e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Vasconcellos?= Date: Thu, 6 Jun 2024 05:13:51 -0300 Subject: [PATCH 02/10] Fixes --- apps/desktop/crates/linux/src/env.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/apps/desktop/crates/linux/src/env.rs b/apps/desktop/crates/linux/src/env.rs index ba7c8b9bc233..986aa3781802 100644 --- a/apps/desktop/crates/linux/src/env.rs +++ b/apps/desktop/crates/linux/src/env.rs @@ -207,16 +207,13 @@ pub fn is_flatpak() -> bool { // Check if system uses a nvidia card to render #[gl_headless] -fn is_nvidia() -> String { - let Some(raw_vendor) = (unsafe { gl::GetString(gl::VENDOR).as_mut() }) else { +fn is_nvidia() -> bool { + let raw_vendor = unsafe { gl::GetString(gl::VENDOR) as *const i8 }; + + if raw_vendor.is_null() { return false; }; - let vendor = unsafe { - CStr::from_ptr(raw_vendor); - }; - return vendor - .to_str() - .unwrap_or("") - .to_lowercase() - .contains("nvidia"); + + let vendor = unsafe { CStr::from_ptr(raw_vendor) }; + return vendor.to_string_lossy().to_lowercase().contains("nvidia"); } From f94bffecebd84da13f81ba7c4a3485adf01969df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Vasconcellos?= Date: Thu, 6 Jun 2024 15:38:00 -0300 Subject: [PATCH 03/10] Don't vendor dbus --- Cargo.lock | 8 ++++---- apps/desktop/src-tauri/Cargo.toml | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index de5285e723b0..ea6093c09ac3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5075,7 +5075,6 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06085512b750d640299b79be4bad3d2fa90a9c00b1fd9e1b46364f66f0485c72" dependencies = [ - "cc", "pkg-config", ] @@ -6710,15 +6709,15 @@ dependencies = [ [[package]] name = "opener" -version = "0.6.1" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c62dcb6174f9cb326eac248f07e955d5d559c272730b6c03e396b443b562788" +checksum = "f8df34be653210fbe9ffaff41d3b92721c56ce82dfee58ee684f9afb5e3a90c0" dependencies = [ "bstr", "dbus", "normpath", "url", - "winapi", + "windows-sys 0.52.0", ] [[package]] @@ -9386,6 +9385,7 @@ name = "sd-desktop" version = "0.3.1" dependencies = [ "axum", + "dbus", "directories 5.0.1", "futures", "http 0.2.11", diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.toml index e09ede7639f8..845598f2a96d 100644 --- a/apps/desktop/src-tauri/Cargo.toml +++ b/apps/desktop/src-tauri/Cargo.toml @@ -28,9 +28,10 @@ tracing = { workspace = true } tauri-specta = { workspace = true, features = ["typescript"] } uuid = { workspace = true, features = ["serde"] } thiserror.workspace = true -directories = "5.0.1" -opener = { version = "0.6.1", features = ["reveal"] } +dbus = { version = "0.9", features = ["stdfd"] } +directories = "5.0.1" +opener = { version = "0.7.1", features = ["reveal"], default-features = false } tauri = { version = "=2.0.0-beta.17", features = [ "macos-private-api", "unstable", From bbc785ad4ed75958d8fc87c2c23b9058c6633694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Vasconcellos?= Date: Thu, 6 Jun 2024 16:39:05 -0300 Subject: [PATCH 04/10] Make dbus and opener linux exclusive dependencies --- apps/desktop/src-tauri/Cargo.toml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.toml index 845598f2a96d..8d8738dc1596 100644 --- a/apps/desktop/src-tauri/Cargo.toml +++ b/apps/desktop/src-tauri/Cargo.toml @@ -14,6 +14,7 @@ sd-core = { path = "../../../core", features = ["ffmpeg", "heif"] } sd-fda = { path = "../../../crates/fda" } sd-prisma = { path = "../../../crates/prisma" } +# Workspace dependencies axum = { workspace = true, features = ["headers", "query"] } hyper = "0.14.28" futures = { workspace = true } @@ -22,16 +23,17 @@ prisma-client-rust = { workspace = true } rand = { workspace = true } rspc = { workspace = true, features = ["tauri", "tracing"] } serde = { workspace = true } +serde_json = { workspace = true } specta = { workspace = true } +strum = { workspace = true, features = ["derive"] } tokio = { workspace = true, features = ["sync"] } tracing = { workspace = true } tauri-specta = { workspace = true, features = ["typescript"] } +thiserror = { workspace = true } uuid = { workspace = true, features = ["serde"] } -thiserror.workspace = true -dbus = { version = "0.9", features = ["stdfd"] } +# Specific Desktop dependencies directories = "5.0.1" -opener = { version = "0.7.1", features = ["reveal"], default-features = false } tauri = { version = "=2.0.0-beta.17", features = [ "macos-private-api", "unstable", @@ -41,10 +43,10 @@ tauri-plugin-updater = "2.0.0-beta" tauri-plugin-dialog = "2.0.0-beta" tauri-plugin-os = "2.0.0-beta" tauri-plugin-shell = "2.0.0-beta" -serde_json.workspace = true -strum = { workspace = true, features = ["derive"] } [target.'cfg(target_os = "linux")'.dependencies] +dbus = { version = "0.9", features = ["stdfd"] } +opener = { version = "0.7.1", features = ["reveal"], default-features = false } sd-desktop-linux = { path = "../crates/linux" } # https://github.com/tauri-apps/tauri/blob/tauri-v2.0.0-beta.17/core/tauri/Cargo.toml#L86 webkit2gtk = { version = "=2.0.1", features = ["v2_38"] } From b252230580f028e63f176c0782cbfc31fd0826c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Vasconcellos?= Date: Thu, 6 Jun 2024 22:06:11 -0300 Subject: [PATCH 05/10] opener is a generic dependency --- apps/desktop/src-tauri/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.toml index 8d8738dc1596..4013280a4789 100644 --- a/apps/desktop/src-tauri/Cargo.toml +++ b/apps/desktop/src-tauri/Cargo.toml @@ -16,7 +16,6 @@ sd-prisma = { path = "../../../crates/prisma" } # Workspace dependencies axum = { workspace = true, features = ["headers", "query"] } -hyper = "0.14.28" futures = { workspace = true } http = { workspace = true } prisma-client-rust = { workspace = true } @@ -34,6 +33,8 @@ uuid = { workspace = true, features = ["serde"] } # Specific Desktop dependencies directories = "5.0.1" +hyper = "0.14.28" +opener = { version = "0.7.1", features = ["reveal"], default-features = false } tauri = { version = "=2.0.0-beta.17", features = [ "macos-private-api", "unstable", @@ -46,7 +47,6 @@ tauri-plugin-shell = "2.0.0-beta" [target.'cfg(target_os = "linux")'.dependencies] dbus = { version = "0.9", features = ["stdfd"] } -opener = { version = "0.7.1", features = ["reveal"], default-features = false } sd-desktop-linux = { path = "../crates/linux" } # https://github.com/tauri-apps/tauri/blob/tauri-v2.0.0-beta.17/core/tauri/Cargo.toml#L86 webkit2gtk = { version = "=2.0.1", features = ["v2_38"] } From fdfea88494ac7c1b48bd34693ac557d73e62eb1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Vasconcellos?= Date: Thu, 6 Jun 2024 22:16:24 -0300 Subject: [PATCH 06/10] Add dbus as a dependency for deb and setup.sh --- apps/desktop/src-tauri/Cargo.toml | 2 ++ apps/desktop/src-tauri/tauri.conf.json | 2 +- scripts/setup.sh | 8 ++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.toml index 4013280a4789..6c1e53369295 100644 --- a/apps/desktop/src-tauri/Cargo.toml +++ b/apps/desktop/src-tauri/Cargo.toml @@ -34,6 +34,7 @@ uuid = { workspace = true, features = ["serde"] } # Specific Desktop dependencies directories = "5.0.1" hyper = "0.14.28" +# WARNING: Do NOT enable default features, as that vendors dbus (see below) opener = { version = "0.7.1", features = ["reveal"], default-features = false } tauri = { version = "=2.0.0-beta.17", features = [ "macos-private-api", @@ -46,6 +47,7 @@ tauri-plugin-os = "2.0.0-beta" tauri-plugin-shell = "2.0.0-beta" [target.'cfg(target_os = "linux")'.dependencies] +# WARNING: dbus must NOT be vendored, as that breaks the app on Linux,X11,Nvidia dbus = { version = "0.9", features = ["stdfd"] } sd-desktop-linux = { path = "../crates/linux" } # https://github.com/tauri-apps/tauri/blob/tauri-v2.0.0-beta.17/core/tauri/Cargo.toml#L86 diff --git a/apps/desktop/src-tauri/tauri.conf.json b/apps/desktop/src-tauri/tauri.conf.json index bb3efbb7aa49..f6334dc17ca3 100644 --- a/apps/desktop/src-tauri/tauri.conf.json +++ b/apps/desktop/src-tauri/tauri.conf.json @@ -59,7 +59,7 @@ "files": { "/usr/share/spacedrive/models/yolov8s.onnx": "../../.deps/models/yolov8s.onnx" }, - "depends": ["libc6", "libxdo3"] + "depends": ["libc6", "libxdo3", "dbus"] } }, diff --git a/scripts/setup.sh b/scripts/setup.sh index b2b9e97e48df..d746d5c2435c 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -143,7 +143,7 @@ case "$(uname)" in # Tauri dependencies set -- build-essential curl wget file openssl libssl-dev libgtk-3-dev librsvg2-dev \ - libwebkit2gtk-4.1-dev libayatana-appindicator3-dev libxdo-dev + libwebkit2gtk-4.1-dev libayatana-appindicator3-dev libxdo-dev libdbus-1-dev # Webkit2gtk requires gstreamer plugins for video playback to work set -- "$@" gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev @@ -161,7 +161,7 @@ case "$(uname)" in echo "Installing dependencies with pacman..." # Tauri dependencies - set -- base-devel curl wget file openssl gtk3 librsvg webkit2gtk-4.1 libayatana-appindicator xdotool + set -- base-devel curl wget file openssl gtk3 librsvg webkit2gtk-4.1 libayatana-appindicator xdotool dbus # Webkit2gtk requires gstreamer plugins for video playback to work set -- "$@" gst-plugins-base gst-plugins-good gst-plugins-ugly @@ -185,7 +185,7 @@ case "$(uname)" in fi # Tauri dependencies - set -- openssl webkit2gtk4.1-devel openssl-dev curl wget file libappindicator-gtk3-devel librsvg2-devel libxdo-devel + set -- openssl webkit2gtk4.1-devel openssl-dev curl wget file libappindicator-gtk3-devel librsvg2-devel libxdo-devel dbus-devel # Webkit2gtk requires gstreamer plugins for video playback to work set -- "$@" gstreamer1-devel gstreamer1-plugins-base-devel gstreamer1-plugins-good \ @@ -205,7 +205,7 @@ case "$(uname)" in # Tauri dependencies set -- build-base curl wget file openssl-dev gtk+3.0-dev librsvg-dev \ - webkit2gtk-4.1-dev libayatana-indicator-dev xdotool + webkit2gtk-4.1-dev libayatana-indicator-dev xdotool-dev dbus-dev # Webkit2gtk requires gstreamer plugins for video playback to work set -- "$@" gst-plugins-base-dev gst-plugins-good gst-plugins-ugly From 6f15078c5cfd1595b8f262c81375f232d53f2afb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Vasconcellos?= Date: Thu, 6 Jun 2024 23:20:21 -0300 Subject: [PATCH 07/10] Clippy fixes --- core/src/api/tags.rs | 2 +- core/src/library/manager/mod.rs | 1 - core/src/object/tag/mod.rs | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/core/src/api/tags.rs b/core/src/api/tags.rs index 84d1e7f30a30..4e534c832704 100644 --- a/core/src/api/tags.rs +++ b/core/src/api/tags.rs @@ -4,7 +4,7 @@ use sd_prisma::{ prisma::{file_path, object, tag, tag_on_object}, prisma_sync, }; -use sd_sync::{option_sync_db_entry, option_sync_entry, sync_entry, OperationFactory}; +use sd_sync::{option_sync_db_entry, OperationFactory}; use sd_utils::{msgpack, uuid_to_bytes}; use std::collections::BTreeMap; diff --git a/core/src/library/manager/mod.rs b/core/src/library/manager/mod.rs index e546f4a9bf7e..309ab003e8e0 100644 --- a/core/src/library/manager/mod.rs +++ b/core/src/library/manager/mod.rs @@ -406,7 +406,6 @@ impl Libraries { .iter() .flatten() .filter_map(|i| RemoteIdentity::from_bytes(&i.remote_identity).ok()) - .into_iter() .any(|i| i == *instance) .then(|| Arc::clone(library)) }), diff --git a/core/src/object/tag/mod.rs b/core/src/object/tag/mod.rs index c6a228c1e4a6..594ddd1cd76e 100644 --- a/core/src/object/tag/mod.rs +++ b/core/src/object/tag/mod.rs @@ -5,7 +5,6 @@ use sd_sync::*; use chrono::{DateTime, FixedOffset, Utc}; -use sd_utils::msgpack; use serde::Deserialize; use specta::Type; use uuid::Uuid; From 41ea7885881da3e61259da6d77fb2baf8b7d8660 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Vasconcellos?= Date: Fri, 7 Jun 2024 01:04:06 -0300 Subject: [PATCH 08/10] Replace gl and glfw with glutin for querying nvidia card --- Cargo.lock | 195 ++++++++++++++++----------- apps/desktop/crates/linux/Cargo.toml | 3 +- apps/desktop/crates/linux/src/env.rs | 33 +++-- 3 files changed, 140 insertions(+), 91 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ea6093c09ac3..88d3224f4c9e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1400,6 +1400,16 @@ dependencies = [ "objc-sys", ] +[[package]] +name = "block2" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15b55663a85f33501257357e6421bb33e769d5c9ffb5ba0921c975a123e35e68" +dependencies = [ + "block-sys", + "objc2 0.4.1", +] + [[package]] name = "block2" version = "0.4.0" @@ -1407,7 +1417,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e58aa60e59d8dbfcc36138f5f18be5f24394d33b38b24f7fd0b1caa33095f22f" dependencies = [ "block-sys", - "objc2", + "objc2 0.5.2", ] [[package]] @@ -1705,12 +1715,27 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" + [[package]] name = "cfg_aliases" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77e53693616d3075149f4ead59bdeecd204ac6b8192d8969757601b74bddf00f" +[[package]] +name = "cgl" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ced0551234e87afee12411d535648dd89d2e7f34c78b753395567aff3d447ff" +dependencies = [ + "libc", +] + [[package]] name = "chacha20" version = "0.9.1" @@ -1848,15 +1873,6 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" -[[package]] -name = "cmake" -version = "0.1.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" -dependencies = [ - "cc", -] - [[package]] name = "cmov" version = "0.3.1" @@ -3767,37 +3783,6 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f924267408915fddcd558e3f37295cc7d6a3e50f8bd8b606cee0808c3915157e" -[[package]] -name = "gl" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a94edab108827d67608095e269cf862e60d920f144a5026d3dbcfd8b877fb404" -dependencies = [ - "gl_generator", -] - -[[package]] -name = "gl-headless" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2a15605d075e3ca0eb9840d9945ce21168c3f66c0422fa929e69b6bdf15a930" -dependencies = [ - "gl", - "gl-headless-macros", - "glfw", -] - -[[package]] -name = "gl-headless-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "912d61fc34c2002bfb42bbd3509f2dc7002534b23bb3f6f5bdade6de1317e60f" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.60", -] - [[package]] name = "gl_generator" version = "0.14.0" @@ -3809,28 +3794,6 @@ dependencies = [ "xml-rs", ] -[[package]] -name = "glfw" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "919ebc7bdbf60a529689a5e58f80d9dcde27e3d2ab4f2f7ce711ec439fe789c5" -dependencies = [ - "bitflags 1.3.2", - "glfw-sys", - "objc", - "raw-window-handle 0.5.2", - "winapi", -] - -[[package]] -name = "glfw-sys" -version = "4.0.0+3.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5abed6d39a50226676aab893d6b4ad154da7e93fcdfed90d7696758a1b477ed1" -dependencies = [ - "cmake", -] - [[package]] name = "glib" version = "0.18.5" @@ -3898,6 +3861,59 @@ dependencies = [ "serde", ] +[[package]] +name = "glutin" +version = "0.31.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18fcd4ae4e86d991ad1300b8f57166e5be0c95ef1f63f3f5b827f8a164548746" +dependencies = [ + "bitflags 2.4.1", + "cfg_aliases 0.1.1", + "cgl", + "core-foundation", + "dispatch", + "glutin_egl_sys", + "glutin_glx_sys", + "glutin_wgl_sys", + "icrate 0.0.4", + "libloading 0.8.1", + "objc2 0.4.1", + "once_cell", + "raw-window-handle 0.5.2", + "wayland-sys", + "windows-sys 0.48.0", + "x11-dl", +] + +[[package]] +name = "glutin_egl_sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77cc5623f5309ef433c3dd4ca1223195347fe62c413da8e2fdd0eb76db2d9bcd" +dependencies = [ + "gl_generator", + "windows-sys 0.48.0", +] + +[[package]] +name = "glutin_glx_sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a165fd686c10dcc2d45380b35796e577eacfd43d4660ee741ec8ebe2201b3b4f" +dependencies = [ + "gl_generator", + "x11-dl", +] + +[[package]] +name = "glutin_wgl_sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8098adac955faa2d31079b65dc48841251f69efd3ac25477903fc424362ead" +dependencies = [ + "gl_generator", +] + [[package]] name = "gobject-sys" version = "0.18.0" @@ -4465,14 +4481,25 @@ dependencies = [ "png", ] +[[package]] +name = "icrate" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d3aaff8a54577104bafdf686ff18565c3b6903ca5782a2026ef06e2c7aa319" +dependencies = [ + "block2 0.3.0", + "dispatch", + "objc2 0.4.1", +] + [[package]] name = "icrate" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e286f4b975ac6c054971a0600a9b76438b332edace54bff79c71c9d3adfc9772" dependencies = [ - "block2", - "objc2", + "block2 0.4.0", + "objc2 0.5.2", ] [[package]] @@ -6622,25 +6649,41 @@ dependencies = [ [[package]] name = "objc-sys" -version = "0.3.2" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7c71324e4180d0899963fc83d9d241ac39e699609fc1025a850aadac8257459" +checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310" [[package]] name = "objc2" -version = "0.5.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a9c7f0d511a4ce26b078183179dca908171cfc69f88986fe36c5138e1834476" +checksum = "559c5a40fdd30eb5e344fbceacf7595a81e242529fb4e21cf5f43fb4f11ff98d" dependencies = [ "objc-sys", - "objc2-encode", + "objc2-encode 3.0.0", +] + +[[package]] +name = "objc2" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46a785d4eeff09c14c487497c162e92766fbb3e4059a71840cecc03d9a50b804" +dependencies = [ + "objc-sys", + "objc2-encode 4.0.3", ] [[package]] name = "objc2-encode" -version = "4.0.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ff06a6505cde0766484f38d8479ac8e6d31c66fbc2d5492f65ca8c091456379" +checksum = "d079845b37af429bfe5dfa76e6d087d788031045b25cfc6fd898486fd9847666" + +[[package]] +name = "objc2-encode" +version = "4.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7891e71393cd1f227313c9379a26a584ff3d7e6e7159e988851f0934c993f0f8" [[package]] name = "objc_exception" @@ -9152,7 +9195,7 @@ dependencies = [ "http-body 0.4.6", "http-range", "hyper 0.14.28", - "icrate", + "icrate 0.1.0", "image", "int-enum", "itertools 0.12.0", @@ -9423,8 +9466,7 @@ dependencies = [ name = "sd-desktop-linux" version = "0.1.0" dependencies = [ - "gl", - "gl-headless", + "glutin", "gtk", "libc", "tokio", @@ -10254,7 +10296,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61d5d17f23326fe0d9b0af282f73f3af666699420fd5f42629efd9c6e7dc166f" dependencies = [ "bytemuck", - "cfg_aliases", + "cfg_aliases 0.2.0", "cocoa", "core-graphics", "foreign-types 0.5.0", @@ -12284,6 +12326,7 @@ checksum = "15a0c8eaff5216d07f226cb7a549159267f3467b289d9a2e52fd3ef5aae2b7af" dependencies = [ "dlib", "log", + "once_cell", "pkg-config", ] diff --git a/apps/desktop/crates/linux/Cargo.toml b/apps/desktop/crates/linux/Cargo.toml index 593540196eca..d33ae1b62c55 100644 --- a/apps/desktop/crates/linux/Cargo.toml +++ b/apps/desktop/crates/linux/Cargo.toml @@ -10,8 +10,7 @@ tokio = { workspace = true, features = ["fs"] } libc = { workspace = true } [target.'cfg(target_os = "linux")'.dependencies] -gl = "0.14" -gl-headless = "0.2" +glutin = "0.31.1" # WARNING: gtk should follow the same version used by tauri # https://github.com/tauri-apps/tauri/blob/tauri-v2.0.0-beta.17/core/tauri/Cargo.toml#L85C1-L85C51 gtk = { version = "0.18", features = [ "v3_24" ] } diff --git a/apps/desktop/crates/linux/src/env.rs b/apps/desktop/crates/linux/src/env.rs index 986aa3781802..537c89296378 100644 --- a/apps/desktop/crates/linux/src/env.rs +++ b/apps/desktop/crates/linux/src/env.rs @@ -8,8 +8,6 @@ use std::{ ptr, }; -use gl_headless::gl_headless; - pub fn get_current_user_home() -> Option { use libc::{getpwuid_r, getuid, passwd, ERANGE}; @@ -178,7 +176,8 @@ pub fn normalize_environment() { ) .expect("PATH must be successfully normalized"); - if is_nvidia() { + if has_nvidia() { + // Workaround for: https://github.com/tauri-apps/tauri/issues/9304 env::set_var("WEBKIT_DISABLE_DMABUF_RENDERER", "1"); } } @@ -205,15 +204,23 @@ pub fn is_flatpak() -> bool { false } -// Check if system uses a nvidia card to render -#[gl_headless] -fn is_nvidia() -> bool { - let raw_vendor = unsafe { gl::GetString(gl::VENDOR) as *const i8 }; - - if raw_vendor.is_null() { - return false; - }; +fn has_nvidia() -> bool { + use glutin::api::egl::device::Device; + + Device::query_devices() + .map(|devices| { + for device in devices { + if device + .vendor() + .unwrap_or("") + .to_lowercase() + .contains("nvidia") + { + return true; + } + } - let vendor = unsafe { CStr::from_ptr(raw_vendor) }; - return vendor.to_string_lossy().to_lowercase().contains("nvidia"); + false + }) + .unwrap_or(false); } From 07d7ad9d8083167978c9611db00a91b0b560b00c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Vasconcellos?= Date: Fri, 7 Jun 2024 02:40:14 -0300 Subject: [PATCH 09/10] Replace glutin with wgpu --- Cargo.lock | 526 ++++++++++++++++++++------- apps/desktop/crates/linux/Cargo.toml | 6 +- apps/desktop/crates/linux/src/env.rs | 35 +- 3 files changed, 418 insertions(+), 149 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 88d3224f4c9e..7b0f4ae8aeb6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -289,6 +289,15 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eab1c04a571841102f5345a8fc0f6bb3d31c315dec879b5c6e42e40ce7ffa34e" +[[package]] +name = "ash" +version = "0.37.3+1.3.251" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e9c3835d686b0a6084ab4234fcd1b07dbf6e4767dce60874b12356a25ecd4a" +dependencies = [ + "libloading 0.7.4", +] + [[package]] name = "ashpd" version = "0.8.1" @@ -1251,7 +1260,7 @@ version = "0.69.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ffcebc3849946a7170a05992aac39da343a90676ab392c51a4280981d6379c2" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.5.0", "cexpr", "clang-sys", "lazy_static", @@ -1268,6 +1277,21 @@ dependencies = [ "which", ] +[[package]] +name = "bit-set" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + [[package]] name = "bit_field" version = "0.10.2" @@ -1282,9 +1306,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" dependencies = [ "serde", ] @@ -1400,16 +1424,6 @@ dependencies = [ "objc-sys", ] -[[package]] -name = "block2" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15b55663a85f33501257357e6421bb33e769d5c9ffb5ba0921c975a123e35e68" -dependencies = [ - "block-sys", - "objc2 0.4.1", -] - [[package]] name = "block2" version = "0.4.0" @@ -1417,7 +1431,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e58aa60e59d8dbfcc36138f5f18be5f24394d33b38b24f7fd0b1caa33095f22f" dependencies = [ "block-sys", - "objc2 0.5.2", + "objc2", ] [[package]] @@ -1574,7 +1588,7 @@ version = "0.18.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ca26ef0159422fb77631dc9d17b102f253b876fe1586b03b803e63a309b4ee2" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.5.0", "cairo-sys-rs", "glib", "libc", @@ -1727,15 +1741,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77e53693616d3075149f4ead59bdeecd204ac6b8192d8969757601b74bddf00f" -[[package]] -name = "cgl" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ced0551234e87afee12411d535648dd89d2e7f34c78b753395567aff3d447ff" -dependencies = [ - "libc", -] - [[package]] name = "chacha20" version = "0.9.1" @@ -1909,6 +1914,16 @@ dependencies = [ "objc", ] +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + [[package]] name = "color_quant" version = "1.1.0" @@ -1931,6 +1946,37 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "com" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e17887fd17353b65b1b2ef1c526c83e26cd72e74f598a8dc1bee13a48f3d9f6" +dependencies = [ + "com_macros", +] + +[[package]] +name = "com_macros" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d375883580a668c7481ea6631fc1a8863e33cc335bf56bfad8d7e6d4b04b13a5" +dependencies = [ + "com_macros_support", + "proc-macro2", + "syn 1.0.109", +] + +[[package]] +name = "com_macros_support" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad899a1087a9296d5644792d7cb72b8e34c1bec8e7d4fbc002230169a6e8710c" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "combine" version = "3.8.1" @@ -2720,6 +2766,15 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "document-features" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef5282ad69563b5fc40319526ba27e0e7363d552a896f0297d54f767717f9b95" +dependencies = [ + "litrs", +] + [[package]] name = "dotenvy" version = "0.15.7" @@ -3733,7 +3788,7 @@ version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "682bdc43cb3c00dbedfcc366de2a849b582efd8d886215dbad2ea662ec156bb5" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.5.0", "bstr", "gix-features", "gix-path", @@ -3800,7 +3855,7 @@ version = "0.18.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "233daaf6e83ae6a12a52055f568f9d7cf4671dabb78ff9560ab6da230ce00ee5" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.5.0", "futures-channel", "futures-core", "futures-executor", @@ -3862,67 +3917,87 @@ dependencies = [ ] [[package]] -name = "glutin" -version = "0.31.3" +name = "glow" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fcd4ae4e86d991ad1300b8f57166e5be0c95ef1f63f3f5b827f8a164548746" +checksum = "bd348e04c43b32574f2de31c8bb397d96c9fcfa1371bd4ca6d8bdc464ab121b1" dependencies = [ - "bitflags 2.4.1", - "cfg_aliases 0.1.1", - "cgl", - "core-foundation", - "dispatch", - "glutin_egl_sys", - "glutin_glx_sys", - "glutin_wgl_sys", - "icrate 0.0.4", - "libloading 0.8.1", - "objc2 0.4.1", - "once_cell", - "raw-window-handle 0.5.2", - "wayland-sys", - "windows-sys 0.48.0", - "x11-dl", + "js-sys", + "slotmap", + "wasm-bindgen", + "web-sys", ] [[package]] -name = "glutin_egl_sys" -version = "0.6.0" +name = "glutin_wgl_sys" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77cc5623f5309ef433c3dd4ca1223195347fe62c413da8e2fdd0eb76db2d9bcd" +checksum = "6c8098adac955faa2d31079b65dc48841251f69efd3ac25477903fc424362ead" dependencies = [ "gl_generator", - "windows-sys 0.48.0", ] [[package]] -name = "glutin_glx_sys" -version = "0.5.0" +name = "gobject-sys" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a165fd686c10dcc2d45380b35796e577eacfd43d4660ee741ec8ebe2201b3b4f" +checksum = "0850127b514d1c4a4654ead6dedadb18198999985908e6ffe4436f53c785ce44" dependencies = [ - "gl_generator", - "x11-dl", + "glib-sys", + "libc", + "system-deps", ] [[package]] -name = "glutin_wgl_sys" -version = "0.5.0" +name = "gpu-alloc" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8098adac955faa2d31079b65dc48841251f69efd3ac25477903fc424362ead" +checksum = "fbcd2dba93594b227a1f57ee09b8b9da8892c34d55aa332e034a228d0fe6a171" dependencies = [ - "gl_generator", + "bitflags 2.5.0", + "gpu-alloc-types", ] [[package]] -name = "gobject-sys" -version = "0.18.0" +name = "gpu-alloc-types" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0850127b514d1c4a4654ead6dedadb18198999985908e6ffe4436f53c785ce44" +checksum = "98ff03b468aa837d70984d55f5d3f846f6ec31fe34bbb97c4f85219caeee1ca4" dependencies = [ - "glib-sys", - "libc", - "system-deps", + "bitflags 2.5.0", +] + +[[package]] +name = "gpu-allocator" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f56f6318968d03c18e1bcf4857ff88c61157e9da8e47c5f29055d60e1228884" +dependencies = [ + "log", + "presser", + "thiserror", + "winapi", + "windows 0.51.1", +] + +[[package]] +name = "gpu-descriptor" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c08c1f623a8d0b722b8b99f821eb0ba672a1618f0d3b16ddbee1cedd2dd8557" +dependencies = [ + "bitflags 2.5.0", + "gpu-descriptor-types", + "hashbrown 0.14.3", +] + +[[package]] +name = "gpu-descriptor-types" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdf242682df893b86f33a73828fb09ca4b2d3bb6cc95249707fc684d27484b91" +dependencies = [ + "bitflags 2.5.0", ] [[package]] @@ -4071,6 +4146,21 @@ dependencies = [ "hashbrown 0.14.3", ] +[[package]] +name = "hassle-rs" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af2a7e73e1f34c48da31fb668a907f250794837e08faa144fd24f0b8b741e890" +dependencies = [ + "bitflags 2.5.0", + "com", + "libc", + "libloading 0.8.1", + "thiserror", + "widestring", + "winapi", +] + [[package]] name = "headers" version = "0.3.9" @@ -4481,25 +4571,14 @@ dependencies = [ "png", ] -[[package]] -name = "icrate" -version = "0.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d3aaff8a54577104bafdf686ff18565c3b6903ca5782a2026ef06e2c7aa319" -dependencies = [ - "block2 0.3.0", - "dispatch", - "objc2 0.4.1", -] - [[package]] name = "icrate" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e286f4b975ac6c054971a0600a9b76438b332edace54bff79c71c9d3adfc9772" dependencies = [ - "block2 0.4.0", - "objc2 0.5.2", + "block2", + "objc2", ] [[package]] @@ -4906,9 +4985,9 @@ checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e" [[package]] name = "js-sys" -version = "0.3.66" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ "wasm-bindgen", ] @@ -4975,11 +5054,22 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b750dcadc39a09dbadd74e118f6dd6598df77fa01df0cfcdc52c28dece74528a" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.5.0", "serde", "unicode-segmentation", ] +[[package]] +name = "khronos-egl" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6aae1df220ece3c0ada96b8153459b67eebe9ae9212258bb0134ae60416fdf76" +dependencies = [ + "libc", + "libloading 0.8.1", + "pkg-config", +] + [[package]] name = "khronos_api" version = "3.1.0" @@ -5631,7 +5721,7 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.5.0", "libc", "redox_syscall 0.4.1", ] @@ -5697,7 +5787,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "761e49ec5fd8a5a463f9b84e877c373d888935b71c6be78f3767fe2ae6bed18e" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.5.0", "libc", ] @@ -5713,6 +5803,12 @@ version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" +[[package]] +name = "litrs" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" + [[package]] name = "lock_api" version = "0.4.11" @@ -5962,6 +6058,21 @@ dependencies = [ "autocfg", ] +[[package]] +name = "metal" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5637e166ea14be6063a3f8ba5ccb9a4159df7d8f6d61c02fc3d480b1f90dcfcb" +dependencies = [ + "bitflags 2.5.0", + "block", + "core-graphics-types", + "foreign-types 0.5.0", + "log", + "objc", + "paste", +] + [[package]] name = "metrics" version = "0.18.1" @@ -6213,6 +6324,25 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16cf681a23b4d0a43fc35024c176437f9dcd818db34e0f42ab456a0ee5ad497b" +[[package]] +name = "naga" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e536ae46fcab0876853bd4a632ede5df4b1c2527a58f6c5a4150fe86be858231" +dependencies = [ + "arrayvec", + "bit-set", + "bitflags 2.5.0", + "codespan-reporting", + "indexmap 2.2.1", + "log", + "num-traits", + "rustc-hash", + "spirv", + "termcolor", + "thiserror", +] + [[package]] name = "nanoid" version = "0.4.0" @@ -6270,7 +6400,7 @@ checksum = "451422b7e4718271c8b5b3aadf5adedba43dc76312454b387e98fae0fc951aa0" dependencies = [ "bitflags 1.3.2", "jni-sys", - "ndk-sys", + "ndk-sys 0.4.1+23.1.7779620", "num_enum", "raw-window-handle 0.5.2", "thiserror", @@ -6291,6 +6421,15 @@ dependencies = [ "jni-sys", ] +[[package]] +name = "ndk-sys" +version = "0.5.0+25.2.9519653" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c196769dd60fd4f363e11d948139556a344e79d451aeb2fa2fd040738ef7691" +dependencies = [ + "jni-sys", +] + [[package]] name = "netlink-packet-core" version = "0.4.2" @@ -6401,7 +6540,7 @@ version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.5.0", "cfg-if", "libc", "memoffset 0.9.0", @@ -6455,7 +6594,7 @@ name = "notify" version = "6.1.1" source = "git+https://github.com/notify-rs/notify.git?rev=c3929ed114fbb0bc7457a9a498260461596b00ca#c3929ed114fbb0bc7457a9a498260461596b00ca" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.5.0", "filetime", "fsevent-sys", "inotify", @@ -6653,16 +6792,6 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310" -[[package]] -name = "objc2" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "559c5a40fdd30eb5e344fbceacf7595a81e242529fb4e21cf5f43fb4f11ff98d" -dependencies = [ - "objc-sys", - "objc2-encode 3.0.0", -] - [[package]] name = "objc2" version = "0.5.2" @@ -6670,15 +6799,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46a785d4eeff09c14c487497c162e92766fbb3e4059a71840cecc03d9a50b804" dependencies = [ "objc-sys", - "objc2-encode 4.0.3", + "objc2-encode", ] -[[package]] -name = "objc2-encode" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d079845b37af429bfe5dfa76e6d087d788031045b25cfc6fd898486fd9847666" - [[package]] name = "objc2-encode" version = "4.0.3" @@ -6769,7 +6892,7 @@ version = "0.10.61" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b8419dc8cc6d866deb801274bba2e6f8f6108c1bb7fcc10ee5ab864931dbb45" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.5.0", "cfg-if", "foreign-types 0.3.2", "libc", @@ -7116,7 +7239,7 @@ version = "0.8.21" source = "git+https://github.com/fogodev/pdfium-render.git?rev=e7aa1111f441c49e857cebda15b4e51b24356aaa#e7aa1111f441c49e857cebda15b4e51b24356aaa" dependencies = [ "bindgen 0.69.1", - "bitflags 2.4.1", + "bitflags 2.5.0", "bytemuck", "bytes", "chrono", @@ -7576,6 +7699,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" +[[package]] +name = "presser" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa" + [[package]] name = "prettyplease" version = "0.2.15" @@ -8419,7 +8548,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.5.0", ] [[package]] @@ -8477,6 +8606,12 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +[[package]] +name = "renderdoc-sys" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" + [[package]] name = "request-handlers" version = "0.1.0" @@ -8775,7 +8910,7 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "549b9d036d571d42e6e85d1c1425e2ac83491075078ca9a15be021c56b1641f2" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.5.0", "chrono", "fallible-iterator", "fallible-streaming-iterator", @@ -8834,7 +8969,7 @@ version = "0.38.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.5.0", "errno", "libc", "linux-raw-sys 0.4.12", @@ -8937,7 +9072,7 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0ae5692c5beaad6a9e22830deeed7874eae8a4e3ba4076fb48e12c56856222c" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.5.0", "bytemuck", "smallvec 1.13.1", "ttf-parser", @@ -9195,7 +9330,7 @@ dependencies = [ "http-body 0.4.6", "http-range", "hyper 0.14.28", - "icrate 0.1.0", + "icrate", "image", "int-enum", "itertools 0.12.0", @@ -9466,10 +9601,10 @@ dependencies = [ name = "sd-desktop-linux" version = "0.1.0" dependencies = [ - "glutin", "gtk", "libc", "tokio", + "wgpu", ] [[package]] @@ -10384,6 +10519,15 @@ dependencies = [ "lock_api", ] +[[package]] +name = "spirv" +version = "0.3.0+sdk-1.3.268.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eda41003dc44290527a59b13432d4a0379379fa074b70174882adfbdfd917844" +dependencies = [ + "bitflags 2.5.0", +] + [[package]] name = "spki" version = "0.6.0" @@ -10756,7 +10900,7 @@ version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92bcf8885e147b56d6e26751263b45876284f32ca404703f6d3b8f80d16ff4dd" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.5.0", "cocoa", "core-foundation", "core-graphics", @@ -10774,7 +10918,7 @@ dependencies = [ "log", "ndk", "ndk-context", - "ndk-sys", + "ndk-sys 0.4.1+23.1.7779620", "objc", "once_cell", "parking_lot 0.12.1", @@ -11195,6 +11339,15 @@ dependencies = [ "utf-8", ] +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + [[package]] name = "thin-slice" version = "0.1.1" @@ -11203,18 +11356,18 @@ checksum = "8eaa81235c7058867fa8c0e7314f33dcce9c215f535d1913822a2b3f5e289f3c" [[package]] name = "thiserror" -version = "1.0.57" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.57" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", @@ -11917,6 +12070,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1d386ff53b415b7fe27b50bb44679e2cc4660272694b7b6f3326d8480823a94" +[[package]] +name = "unicode-width" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" + [[package]] name = "unicode-xid" version = "0.2.4" @@ -12228,9 +12387,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.89" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -12238,9 +12397,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.89" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", @@ -12253,9 +12412,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.39" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac36a15a220124ac510204aec1c3e5db8a22ab06fd6706d881dc6149f8ed9a12" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" dependencies = [ "cfg-if", "js-sys", @@ -12265,9 +12424,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.89" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -12275,9 +12434,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.89" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", @@ -12288,9 +12447,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.89" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "wasm-streams" @@ -12326,15 +12485,14 @@ checksum = "15a0c8eaff5216d07f226cb7a549159267f3467b289d9a2e52fd3ef5aae2b7af" dependencies = [ "dlib", "log", - "once_cell", "pkg-config", ] [[package]] name = "web-sys" -version = "0.3.66" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" dependencies = [ "js-sys", "wasm-bindgen", @@ -12489,6 +12647,110 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082" +[[package]] +name = "wgpu" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32ff1bfee408e1028e2e3acbf6d32d98b08a5a059ccbf5f33305534453ba5d3e" +dependencies = [ + "arrayvec", + "cfg-if", + "cfg_aliases 0.1.1", + "document-features", + "js-sys", + "log", + "parking_lot 0.12.1", + "profiling", + "raw-window-handle 0.6.1", + "smallvec 1.13.1", + "static_assertions", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "wgpu-core", + "wgpu-hal", + "wgpu-types", +] + +[[package]] +name = "wgpu-core" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac6a86eaa5e763e59c73cf9e97d55fffd4dfda69fd8bda19589fcf851ddfef1f" +dependencies = [ + "arrayvec", + "bit-vec", + "bitflags 2.5.0", + "cfg_aliases 0.1.1", + "codespan-reporting", + "document-features", + "indexmap 2.2.1", + "log", + "naga", + "once_cell", + "parking_lot 0.12.1", + "profiling", + "raw-window-handle 0.6.1", + "rustc-hash", + "smallvec 1.13.1", + "thiserror", + "web-sys", + "wgpu-hal", + "wgpu-types", +] + +[[package]] +name = "wgpu-hal" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d71c8ae05170583049b65ee562fd839fdc0b3e9ddb84f4e40c9d5f8ea0d4c8c" +dependencies = [ + "android_system_properties", + "arrayvec", + "ash", + "bitflags 2.5.0", + "cfg_aliases 0.1.1", + "core-graphics-types", + "glow", + "glutin_wgl_sys", + "gpu-alloc", + "gpu-allocator", + "gpu-descriptor", + "hassle-rs", + "js-sys", + "khronos-egl", + "libc", + "libloading 0.8.1", + "log", + "metal", + "naga", + "ndk-sys 0.5.0+25.2.9519653", + "objc", + "once_cell", + "parking_lot 0.12.1", + "profiling", + "raw-window-handle 0.6.1", + "renderdoc-sys", + "rustc-hash", + "smallvec 1.13.1", + "thiserror", + "wasm-bindgen", + "web-sys", + "wgpu-types", + "winapi", +] + +[[package]] +name = "wgpu-types" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1353d9a46bff7f955a680577f34c69122628cc2076e1d6f3a9be6ef00ae793ef" +dependencies = [ + "bitflags 2.5.0", + "js-sys", + "web-sys", +] + [[package]] name = "which" version = "4.4.2" @@ -12993,7 +13255,7 @@ dependencies = [ "libc", "ndk", "ndk-context", - "ndk-sys", + "ndk-sys 0.4.1+23.1.7779620", "objc", "objc_id", "once_cell", diff --git a/apps/desktop/crates/linux/Cargo.toml b/apps/desktop/crates/linux/Cargo.toml index d33ae1b62c55..107b9226eff8 100644 --- a/apps/desktop/crates/linux/Cargo.toml +++ b/apps/desktop/crates/linux/Cargo.toml @@ -7,10 +7,10 @@ edition = { workspace = true } [dependencies] tokio = { workspace = true, features = ["fs"] } -libc = { workspace = true } +libc = { workspace = true } [target.'cfg(target_os = "linux")'.dependencies] -glutin = "0.31.1" +wgpu = { version = "0.20.0", default-features = false } # WARNING: gtk should follow the same version used by tauri # https://github.com/tauri-apps/tauri/blob/tauri-v2.0.0-beta.17/core/tauri/Cargo.toml#L85C1-L85C51 -gtk = { version = "0.18", features = [ "v3_24" ] } +gtk = { version = "0.18", features = ["v3_24"] } diff --git a/apps/desktop/crates/linux/src/env.rs b/apps/desktop/crates/linux/src/env.rs index 537c89296378..e639c7964644 100644 --- a/apps/desktop/crates/linux/src/env.rs +++ b/apps/desktop/crates/linux/src/env.rs @@ -205,22 +205,29 @@ pub fn is_flatpak() -> bool { } fn has_nvidia() -> bool { - use glutin::api::egl::device::Device; - - Device::query_devices() - .map(|devices| { - for device in devices { - if device - .vendor() - .unwrap_or("") - .to_lowercase() - .contains("nvidia") - { + use wgpu::{ + Backends, DeviceType, Dx12Compiler, Gles3MinorVersion, Instance, InstanceDescriptor, + InstanceFlags, + }; + + let instance = Instance::new(InstanceDescriptor { + flags: InstanceFlags::empty(), + backends: Backends::VULKAN | Backends::GL, + gles_minor_version: Gles3MinorVersion::Automatic, + dx12_shader_compiler: Dx12Compiler::default(), + }); + for adapter in instance.enumerate_adapters(Backends::all()) { + let info = adapter.get_info(); + match info.device_type { + DeviceType::DiscreteGpu | DeviceType::IntegratedGpu | DeviceType::VirtualGpu => { + // Nvidia PCI id + if info.vendor == 0x10de { return true; } } + _ => {} + } + } - false - }) - .unwrap_or(false); + false } From 9fe722021206cc6fd8a08c063412e5399a0e2103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Vasconcellos?= Date: Fri, 7 Jun 2024 05:35:25 -0300 Subject: [PATCH 10/10] Update icrate to fix 'multiple applicable items in scope' --- Cargo.lock | 4 ++-- core/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7b0f4ae8aeb6..2c085bf3372c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4573,9 +4573,9 @@ dependencies = [ [[package]] name = "icrate" -version = "0.1.0" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e286f4b975ac6c054971a0600a9b76438b332edace54bff79c71c9d3adfc9772" +checksum = "3fb69199826926eb864697bddd27f73d9fddcffc004f5733131e15b465e30642" dependencies = [ "block2", "objc2", diff --git a/core/Cargo.toml b/core/Cargo.toml index bd2fe08bade6..30f65ca252f4 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -151,7 +151,7 @@ trash = "4.1.0" trash = "4.1.0" [target.'cfg(target_os = "ios")'.dependencies] -icrate = { version = "0.1.0", features = [ +icrate = { version = "0.1.2", features = [ "Foundation", "Foundation_NSFileManager", "Foundation_NSString",