SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Graphics: choose the graphics card, honour WGPU_ADAPTER_NAME (#5986) (#6010)
raykholob1da434458a8
diff --git a/apps/solidcraft/src/main.rs b/apps/solidcraft/src/main.rsindex e053850fdf..a7e3b3755e 100644--- a/apps/solidcraft/src/main.rs+++ b/apps/solidcraft/src/main.rs@@ -335,6 +335,7 @@ fn services(cc: &eframe::CreationContext<'_>) -> Services {let future = dialog.save_file();Box::pin(async move { future.await.map(|p| p.path().to_string_lossy().into_owned()) })})),+ graphics_adapters: Vec::new(),graphics_path: graphics_path().map(|p| p.to_string_lossy().to_string()),window_system: window_system_now(),http_get: Some(std::sync::Arc::new(http_get)),@@ -802,7 +803,19 @@ fn main() -> eframe::Result {restart_on_software: device_lost::restart_on_software(after_loss, cpu_renderer),lost_at: None,});+ if !safe_mode {+ app.preferences.graphics_adapter =+ graphics().and_then(|v| v.get("adapter").and_then(serde_json::Value::as_str).map(str::to_string)).unwrap_or_default();+ }if let Some(rs) = &cc.wgpu_render_state {+ app.services.graphics_adapters = rs+ .available_adapters+ .iter()+ .map(|adapter| {+ let info = adapter.get_info();+ (info.name.clone(), format!("{} ({:?}, {:?})", info.name, info.device_type, info.backend))+ })+ .collect();let scene_samples = scene_samples(rs.adapter.get_info().backend, u32::from(samples), &rs.msaa_supported);eprintln!("SolidCraft graphics: {:?}, MSAA {scene_samples}x (requested {}x)", rs.adapter.get_info().backend, samples);solidcraft_engine::crash::phase("viewport pipelines (shader compile)");@@ -935,9 +948,9 @@ fn wgpu_options(cpu: bool, preference: Option<&str>) -> eframe::egui_wgpu::WgpuClet intel_mac = cfg!(all(target_os = "macos", target_arch = "x86_64"));let indirect = std::env::var(startup::INDIRECT_VALIDATION_ENV).ok();setup.instance_descriptor.flags = startup::window_instance_flags(setup.instance_descriptor.flags, intel_mac, indirect.as_deref());- if cpu {- setup.native_adapter_selector = Some(std::sync::Arc::new(startup::pick_cpu_adapter));- }+ let environment = std::env::var("WGPU_ADAPTER_NAME").ok();+ let adapter = graphics().and_then(|v| v.get("adapter").and_then(serde_json::Value::as_str).map(str::to_string));+ startup::configure_adapter(setup, cpu, environment, adapter);// A float depth buffer with a stencil, wherever the adapter has it (see `FLOAT_DEPTH_BITS`).let base = setup.device_descriptor.clone();setup.device_descriptor = std::sync::Arc::new(move |adapter| {diff --git a/apps/solidcraft/src/startup.rs b/apps/solidcraft/src/startup.rsindex 7ff747ddea..df01438ad4 100644--- a/apps/solidcraft/src/startup.rs+++ b/apps/solidcraft/src/startup.rs@@ -129,6 +129,48 @@ pub fn pick_cpu_adapter(adapters: &[eframe::wgpu::Adapter], surface: Option<&efr})}+/// Adapter properties used to choose a card without opening a device.+#[derive(Clone, Debug)]+pub struct AdapterChoice {+ pub name: String,+ pub compatible: bool,+}++/// Choose only surface-compatible adapters. Names saved in preferences are exact; the+/// environment override follows wgpu's case-insensitive substring convention.+/// No match leaves selection to the normal wgpu request.+pub fn choose_adapter(adapters: &[AdapterChoice], environment: Option<&str>, preference: Option<&str>) -> Option<usize> {+ // wgpu's environment helper panics on a missing name; an override must remain recoverable.+ let compatible = || adapters.iter().enumerate().filter(|(_, a)| a.compatible);+ if let Some(name) = environment.filter(|s| !s.is_empty()) {+ let name = name.to_lowercase();+ if let Some((index, _)) = compatible().find(|(_, a)| a.name.to_lowercase().contains(&name)) {+ return Some(index);+ }+ }+ if let Some(name) = preference.filter(|s| !s.is_empty())+ && let Some((index, _)) = compatible().find(|(_, a)| a.name == name)+ {+ return Some(index);+ }+ None+}++/// Leave Automatic on wgpu's normal request path; named choices may defer to it too.+pub fn configure_adapter(setup: &mut eframe::egui_wgpu::WgpuSetupCreateNew, cpu: bool, environment: Option<String>, preference: Option<String>) {+ if cpu {+ setup.native_adapter_selector = Some(std::sync::Arc::new(|adapters, surface| pick_cpu_adapter(adapters, surface).map(Some)));+ } else if environment.as_deref().is_some_and(|s| !s.is_empty()) || preference.as_deref().is_some_and(|s| !s.is_empty()) {+ setup.native_adapter_selector = Some(std::sync::Arc::new(move |adapters, surface| {+ let choices: Vec<_> = adapters+ .iter()+ .map(|a| AdapterChoice { name: a.get_info().name, compatible: surface.is_none_or(|s| a.is_surface_supported(s)) })+ .collect();+ Ok(choose_adapter(&choices, environment.as_deref(), preference.as_deref()).and_then(|i| adapters.get(i)).cloned())+ }));+ }+}+/// `WGPU_BACKEND`: when set, wgpu picks the backends from it and the order below is not used.pub const WGPU_BACKEND_ENV: &str = "WGPU_BACKEND";@@ -249,6 +291,48 @@ pub fn no_window_message(error: &str, settings: Option<&Path>) -> String {mod tests {use super::*;+ fn cards() -> Vec<AdapterChoice> {+ ["Integrated", "Discrete small", "Discrete large"].into_iter().map(|name| AdapterChoice { name: name.into(), compatible: true }).collect()+ }++ #[test]+ fn adapter_names_environment_override_and_missing_card_fallback() {+ let cards = cards();+ assert_eq!(choose_adapter(&cards, None, Some("Discrete small")), Some(1));+ assert_eq!(choose_adapter(&cards, Some("LARGE"), Some("Discrete small")), Some(2));+ assert_eq!(choose_adapter(&cards, None, Some("removed")), None);+ assert_eq!(choose_adapter(&cards, Some("missing"), Some("Discrete small")), Some(1));+ assert_eq!(choose_adapter(&cards, Some(""), Some("Discrete small")), Some(1));+ assert_eq!(choose_adapter(&cards, None, Some("Discrete")), None, "saved names are exact");+ }++ #[test]+ fn automatic_adapter_leaves_selection_to_wgpu() {+ let mut cards = cards();+ assert_eq!(choose_adapter(&cards, None, None), None);+ assert_eq!(choose_adapter(&cards, Some(""), Some("")), None);+ cards[2].compatible = false;+ assert_eq!(choose_adapter(&cards, Some("large"), Some("Discrete large")), None);+ assert_eq!(choose_adapter(&cards, Some("small"), None), Some(1));+ assert_eq!(choose_adapter(&[], None, None), None);+ }++ #[test]+ fn automatic_adapter_preserves_the_previous_request_configuration() {+ use eframe::egui_wgpu::WgpuSetupCreateNew;+ let previous = WgpuSetupCreateNew::without_display_handle();+ for preference in [None, Some(String::new())] {+ let mut setup = WgpuSetupCreateNew::without_display_handle();+ configure_adapter(&mut setup, false, None, preference);+ assert!(setup.native_adapter_selector.is_none(), "Automatic must use the normal wgpu request");+ assert_eq!(setup.power_preference, previous.power_preference);+ assert_eq!(setup.instance_descriptor.backends, previous.instance_descriptor.backends);+ }+ let mut setup = WgpuSetupCreateNew::without_display_handle();+ configure_adapter(&mut setup, false, Some("missing".into()), Some("removed".into()));+ assert!(setup.native_adapter_selector.unwrap()(&[], None).unwrap().is_none(), "missing names must use the normal request too");+ }+fn scratch(name: &str) -> PathBuf {let d = std::env::temp_dir().join(format!("solidcraft-startup-{name}-{}", std::process::id()));let _ = std::fs::remove_dir_all(&d);diff --git a/assets/locales/pending/graphics-card.json b/assets/locales/pending/graphics-card.jsonnew file mode 100644index 0000000000..30fc1c4793--- /dev/null+++ b/assets/locales/pending/graphics-card.json@@ -0,0 +1,20 @@+{+ "en": {+ "prefs.graphics_card": "Graphics card",+ "prefs.graphics_card_auto": "Automatic",+ "prefs.graphics_card_missing": "The saved graphics card is unavailable; Automatic is used.",+ "prefs.graphics_card_restart": "Takes effect after restarting SolidCraft. WGPU_ADAPTER_NAME overrides this choice."+ },+ "ja": {+ "prefs.graphics_card": "グラフィックスカード",+ "prefs.graphics_card_auto": "自動",+ "prefs.graphics_card_missing": "保存されたグラフィックスカードが利用できないため、自動選択を使用します。",+ "prefs.graphics_card_restart": "SolidCraft の再起動後に有効になります。WGPU_ADAPTER_NAME がこの選択より優先されます。"+ },+ "zh": {+ "prefs.graphics_card": "显卡",+ "prefs.graphics_card_auto": "自动",+ "prefs.graphics_card_missing": "已保存的显卡不可用;将使用自动选择。",+ "prefs.graphics_card_restart": "重启 SolidCraft 后生效。WGPU_ADAPTER_NAME 优先于此选择。"+ }+}diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rsindex 546600da1d..3f78d14b35 100644--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@ -359,6 +359,8 @@ pub struct Services {pub graphics_path: Option<String>,/// Linux: the window system this run uses, `wayland` or `x11` (Preferences shows it, #3083).pub window_system: Option<&'static str>,+ /// Adapter names and descriptive labels from the desktop renderer's chosen backends.+ pub graphics_adapters: Vec<(String, String)>,/// HTTPS GET for the update check (`update`); None: never check (browser, tests).pub http_get: Option<update::HttpGet>,/// HTTPS download to a file, with progress, for one-click updates (`update::install`).diff --git a/crates/ui-egui/src/prefs.rs b/crates/ui-egui/src/prefs.rsindex dee99d8d92..8b2b0104ed 100644--- a/crates/ui-egui/src/prefs.rs+++ b/crates/ui-egui/src/prefs.rs@@ -513,6 +513,8 @@ preference_settings! {/// Linux: the window system the app opens with at its next start (#3083): `auto` (XWayland/// whenever there is an X display, native Wayland on niri), `wayland` or `x11`.window_system: String = "auto".into(), PAGE_GRAPHICS;+ /// Exact graphics adapter name; empty selects automatically on the next start.+ graphics_adapter: String = String::new(), PAGE_GRAPHICS;/// Soft contact shading in the GPU viewport; optional and applied immediately.ambient_occlusion: bool = false, PAGE_GRAPHICS;/// Optional schematic markings on threaded cylindrical walls; off for new and older preferences.@@ -763,7 +765,7 @@ impl Snapshot {}}fn restore(self, app: &mut SolveApp) {- let graphics = (app.preferences.msaa, app.preferences.window_system.clone());+ let graphics = (app.preferences.msaa, app.preferences.window_system.clone(), app.preferences.graphics_adapter.clone());let units_changed = app.preferences.default_units != self.prefs.default_units;// Update bookkeeping isn't a setting: a check that finished while the dialog was open stays.let update = std::mem::take(&mut app.preferences.update);@@ -784,7 +786,7 @@ impl Snapshot {set_autosave(app);app.session.auto_project = self.auto_project;app.keymap.custom = self.keys;- if (app.preferences.msaa, app.preferences.window_system.clone()) != graphics {+ if (app.preferences.msaa, app.preferences.window_system.clone(), app.preferences.graphics_adapter.clone()) != graphics {save_graphics(app);}}@@ -939,7 +941,7 @@ fn ui_font_row(app: &mut SolveApp, ui: &mut egui::Ui) {/// Restore Defaults for one page.fn defaults(app: &mut SolveApp, page: usize) {- let (msaa, window_system) = (app.preferences.msaa, app.preferences.window_system.clone());+ let (msaa, window_system, adapter) = (app.preferences.msaa, app.preferences.window_system.clone(), app.preferences.graphics_adapter.clone());let units = app.preferences.default_units.clone();reset_preferences(&mut app.preferences, page);if app.preferences.default_units != units {@@ -962,7 +964,7 @@ fn defaults(app: &mut SolveApp, page: usize) {app.ui.show_grid = true;app.ui.ground_shadow = true;app.ui.perspective = false;- if app.preferences.msaa != msaa || app.preferences.window_system != window_system {+ if app.preferences.msaa != msaa || app.preferences.window_system != window_system || app.preferences.graphics_adapter != adapter {save_graphics(app);}}@@ -1206,6 +1208,7 @@ fn save_graphics(app: &SolveApp) {.unwrap_or_else(|| json!({}));graphics["msaa"] = json!(app.preferences.msaa);graphics["window_system"] = json!(app.preferences.window_system);+ graphics["adapter"] = json!(app.preferences.graphics_adapter);let _ = std::fs::write(path, graphics.to_string());}}@@ -1318,7 +1321,10 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {ui_kit::Action::Cancel => Some("cancel"),ui_kit::Action::None => button,};- if app.preferences.msaa != before.msaa || app.preferences.window_system != before.window_system {+ if app.preferences.msaa != before.msaa+ || app.preferences.window_system != before.window_system+ || app.preferences.graphics_adapter != before.graphics_adapter+ {save_graphics(app);}if app.preferences.up_axis != before.up_axis {@@ -2168,6 +2174,9 @@ pub fn set(app: &mut SolveApp, p: &serde_json::Value) -> Result<serde_json::Valuif new.msaa != app.preferences.msaa && !app.msaa_supported.is_empty() && !app.msaa_supported.contains(&new.msaa) {return Err(format!("this graphics device doesn't support `msaa` {}; it supports {:?}", new.msaa, app.msaa_supported));}+ if new.graphics_adapter.len() > 1024 || new.graphics_adapter.chars().any(char::is_control) {+ return Err("`graphics_adapter` must be a name of at most 1024 bytes without control characters".into());+ }let file = crate::theme_files::find(&new.theme, &new.custom_themes);if (!THEMES.iter().any(|(id, _)| *id == new.theme) && file.is_none()) || !["z", "y"].contains(&new.up_axis.as_str()) {return Err("`theme` must be dark, light, system or a theme's id (see `theme_ids`) and `up_axis` z or y".into());@@ -2206,7 +2215,9 @@ pub fn set(app: &mut SolveApp, p: &serde_json::Value) -> Result<serde_json::Valu}let units_changed = new.default_units != app.preferences.default_units;let up_changed = new.up_axis != app.preferences.up_axis;- let msaa_changed = new.msaa != app.preferences.msaa || new.window_system != app.preferences.window_system;+ let graphics_changed = new.msaa != app.preferences.msaa+ || new.window_system != app.preferences.window_system+ || new.graphics_adapter != app.preferences.graphics_adapter;if p.get("layout").is_some() {app.ui.layout = new.layout;}@@ -2214,7 +2225,7 @@ pub fn set(app: &mut SolveApp, p: &serde_json::Value) -> Result<serde_json::Valuif units_changed {default_units_changed(app);}- if msaa_changed {+ if graphics_changed {save_graphics(app);}if up_changed {@@ -3560,6 +3571,51 @@ mod tests {let _ = std::fs::remove_dir_all(&dir);}+ #[test]+ fn graphics_card_picker_selects_named_cards_and_restores_automatic() {+ let dir = std::env::temp_dir().join(format!("solidcraft-graphics-picker-{}", std::process::id()));+ std::fs::create_dir_all(&dir).unwrap();+ let mut h = crate::scenario::Harness::new();+ h.app.services.graphics_path = Some(dir.join("graphics.json").to_string_lossy().into_owned());+ h.app.services.graphics_adapters = vec![("Discrete small".into(), "Discrete small (DiscreteGpu, Vulkan)".into())];+ h.call("ui.prefs", json!({"open":"Graphics"}));+ super::reveal_preference(&mut h, "prefs:graphics_card");+ assert!(h.app.preferences.graphics_adapter.is_empty());+ h.step(&json!({"click":{"handle":"prefs:graphics_card"}})).unwrap();+ h.step(&json!({"click":{"handle":"dialog:list:graphics_card:0"}})).unwrap();+ assert_eq!(h.app.preferences.graphics_adapter, "Discrete small");+ h.step(&json!({"click":{"handle":"prefs:graphics_card"}})).unwrap();+ h.step(&json!({"click":{"handle":"dialog:list:graphics_card:auto"}})).unwrap();+ assert!(h.app.preferences.graphics_adapter.is_empty());+ std::fs::remove_dir_all(dir).unwrap();+ }++ #[test]+ fn graphics_card_preference_persists_cancels_and_resets_without_changing_backend() {+ let dir = std::env::temp_dir().join(format!("solidcraft-graphics-card-{}", std::process::id()));+ std::fs::create_dir_all(&dir).unwrap();+ let path = dir.join("graphics.json");+ std::fs::write(&path, r#"{"backend":"vulkan","msaa":4}"#).unwrap();+ let services = crate::Services { graphics_path: Some(path.to_string_lossy().into()), ..Default::default() };+ let mut app = SolveApp::new(solidcraft_engine::Session::default(), services);+ let snapshot = Snapshot::take(&app);+ set(&mut app, &json!({"graphics_adapter":"Discrete large"})).unwrap();+ let read = || serde_json::from_str::<serde_json::Value>(&std::fs::read_to_string(&path).unwrap()).unwrap();+ assert_eq!(read()["adapter"], "Discrete large");+ assert_eq!(read()["backend"], "vulkan");+ let saved = serde_json::to_value(&app.preferences).unwrap();+ assert_eq!(lenient(&saved).graphics_adapter, "Discrete large");+ snapshot.restore(&mut app);+ assert_eq!(read()["adapter"], "");+ set(&mut app, &json!({"graphics_adapter":"Discrete small"})).unwrap();+ defaults(&mut app, PAGE_GRAPHICS);+ assert_eq!(read()["adapter"], "");+ assert_eq!(read()["backend"], "vulkan");+ assert!(set(&mut app, &json!({"graphics_adapter":"x".repeat(1025)})).is_err());+ assert!(set(&mut app, &json!({"graphics_adapter":"card\nname"})).is_err());+ std::fs::remove_dir_all(dir).unwrap();+ }+#[test]fn unsupported_saved_msaa_is_reset_to_the_default_with_a_notice() {let dir = std::env::temp_dir().join(format!("sc_msaa_reset_{}", std::process::id()));diff --git a/crates/ui-egui/src/prefs/graphics.rs b/crates/ui-egui/src/prefs/graphics.rsindex efef8ae1d8..bb46fc7121 100644--- a/crates/ui-egui/src/prefs/graphics.rs+++ b/crates/ui-egui/src/prefs/graphics.rs@@ -4,6 +4,33 @@ use super::*;pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) {let t = crate::theme::Tokens::get();ui_kit::settings_heading(ui, app.tr("prefs.graphics"), app.tr("prefs.graphics_note"));+ if app.services.graphics_path.is_some() {+ ui_kit::settings_section(ui, "graphics_card", app.tr("prefs.graphics_card"), |ui| {+ let adapters = &app.services.graphics_adapters;+ let selected = adapters.iter().position(|(name, _)| *name == app.preferences.graphics_adapter);+ let missing = !app.preferences.graphics_adapter.is_empty() && selected.is_none();+ let current = selected.and_then(|i| adapters.get(i)).map_or(app.tr("prefs.graphics_card_auto"), |(_, label)| label.as_str());+ let mut requested = None;+ let response = ui_kit::dropdown_menu(ui, "graphics_card", current, |ui| {+ if ui_kit::list_picker(ui, "graphics_card:auto", app.tr("prefs.graphics_card_auto"), selected.is_none()).clicked() {+ requested = Some(String::new());+ }+ for (index, (name, label)) in adapters.iter().enumerate() {+ if ui_kit::list_picker(ui, &format!("graphics_card:{index}"), label, selected == Some(index)).clicked() {+ requested = Some(name.clone());+ }+ }+ });+ crate::scenario::publish_target("prefs:graphics_card", response.rect);+ if let Some(name) = requested {+ let _ = super::set(app, &json!({"graphics_adapter": name}));+ }+ ui_kit::text(ui, app.tr("prefs.graphics_card_restart"), ui_kit::Text::Hint("graphics_card_restart"));+ if missing {+ ui_kit::text(ui, app.tr("prefs.graphics_card_missing"), ui_kit::Text::Hint("graphics_card_missing"));+ }+ });+ }ui.horizontal_wrapped(|ui| {let response =ui.allocate_ui_with_layout(egui::vec2(t.form_card_width + t.space_24 * 2.0, 0.0), egui::Layout::top_down(egui::Align::Min), |ui| {diff --git a/docs/control-protocol.md b/docs/control-protocol.mdindex 18538a5a39..7602fb1036 100644--- a/docs/control-protocol.md+++ b/docs/control-protocol.md@@ -245,7 +245,7 @@ labels; `prefs:measure_axis_distances` identifies the checkbox.| `ui.home` | `open?`: bool; `sample?`: index | the start page: show or hide it, open a built-in sample (once built); returns `open` and the recent designs || `ui.shortcut` | `command`, `key?`, `replace?` | a command's key, or rebinds it (`""` clears; a key another command uses is refused unless `replace`) || `ui.help` | `item?`: `about`, `shortcuts` (read only), `report` (opens a report draft for review), `crashes` (the Crash Reports window) | the version, commit, build date and diagnostic text |-| `ui.prefs` | any of `default_units`, `nav` (`fusion`, `solidworks`, `inventor`, `alias`, `blender`, `tinkercad`, `openscad`, `touchpad`), `zoom_reverse`, `pan_reverse_x` (default false: horizontal scrolling pans the other way), `zoom_to_cursor`, `smooth_wheel_zoom` (default true), `trackpad_pan` (default true: two-finger scroll pans, except Touchpad always zooms; pinch zooms), `orbit_around` (`view_centre` (default: what Pan moves and Fit frames), `origin` (the world origin stays still on screen), `cursor` (the model point under the pointer when the drag began); the older `orbit_cursor` boolean still sets `cursor` when true), `look_at_anim`, `look_at_speed`, `middle_double_click` (`home` (default), `fit`, `off`), `msaa`, `show_frame_rate` (default false: frames per second in the view's bottom-right corner, counting the frames the view draws anyway; it reads 0 FPS once the view is idle), `window_system` (Linux: `auto` (default: XWayland whenever there is an X display, native Wayland on niri), `wayland`, `x11`; saved in `graphics.json`, applies at the next start; `SOLIDCRAFT_WAYLAND` overrides it), `frame_rate_details` (default false: with the frame rate, a frame-time graph of the frames drawn with the triangles over it, a frame-time histogram and what the GPU drew; clicking the readout switches it), `length_decimals`, `angle_decimals`, `step_values` (default false: Up/Down and the wheel step a plain number in a focused value field), `theme` (`dark`, `light`, `system` or a theme file's id: a built-in one such as `gruvbox-dark`, or an imported one; the reply's `theme_ids` lists them), `theme_import` (a `solidcraft-theme/1` file's JSON or text: adds the theme and turns it on; the reply's `theme_imported` is its id), `theme_remove` (an imported theme's id), `theme_export: true` (the reply's `theme_file` is the theme on now as a complete file; see [colour themes](book/src/guide/ui-tour.md#colour-themes)), `language` (`en`, `ja`, `de`, `fr`, `ko`, `ms`, `ru`, `uk`, `zh`; see [localization](localization.md)), `ui_scale`, `ui_font` (an installed font family or a font file for the interface; empty for the built-in font), `up_axis` (`z`, `y`), `offer_stand_up`, `extrude_auto_to_object` (default false: in the Extrude dialog, with a profile picked, a face, vertex or parallel plane picked off its plane switches the extent to To Object; it applies to Extrude dialogs opened afterwards), `hole_snaps` (default false: a Single hole snaps to its face's middle and round edges' centres), `hole_moves` (default false: a placed Single hole has a drag handle (`hole:<n>`), and a pick on a face that has a hole moves it there), `color_vision` (`off` (default), `protan`, `deutan`, `tritan`: colour vision modes, #778), `check_updates` (default true; [updates](book/src/guide/updates.md)); `open` (a page: General, Interface, Design, Navigation, Keyboard Shortcuts, Sketch, Graphics, AI, Plugins; Shortcuts, Assistant and Sketch & selection are aliases, and the former Selection page opens Sketch) opens the Preferences dialog there; `button`: `ok`, `cancel`, `apply`, `defaults`; `stand_up: true` stands up a just-opened Y-up file, `stand_up: false` leaves it as it is ("Leave it": the offer closes and `offer_stand_up` stays on); the offer's buttons are the handles `stand_up:stand`, `stand_up:leave` and `stand_up:never` | sets preferences (kept between runs), returns them all plus `dialog` (the open page or null), `dark` and `stand_up_offer` |+| `ui.prefs` | any of `default_units`, `nav` (`fusion`, `solidworks`, `inventor`, `alias`, `blender`, `tinkercad`, `openscad`, `touchpad`), `zoom_reverse`, `pan_reverse_x` (default false: horizontal scrolling pans the other way), `zoom_to_cursor`, `smooth_wheel_zoom` (default true), `trackpad_pan` (default true: two-finger scroll pans, except Touchpad always zooms; pinch zooms), `orbit_around` (`view_centre` (default: what Pan moves and Fit frames), `origin` (the world origin stays still on screen), `cursor` (the model point under the pointer when the drag began); the older `orbit_cursor` boolean still sets `cursor` when true), `look_at_anim`, `look_at_speed`, `middle_double_click` (`home` (default), `fit`, `off`), `msaa`, `show_frame_rate` (default false: frames per second in the view's bottom-right corner, counting the frames the view draws anyway; it reads 0 FPS once the view is idle), `window_system` (Linux: `auto` (default: XWayland whenever there is an X display, native Wayland on niri), `wayland`, `x11`; saved in `graphics.json`, applies at the next start; `SOLIDCRAFT_WAYLAND` overrides it), `graphics_adapter` (exact card name, or empty for Automatic; applies after restart; `WGPU_ADAPTER_NAME` takes precedence), `frame_rate_details` (default false: with the frame rate, a frame-time graph of the frames drawn with the triangles over it, a frame-time histogram and what the GPU drew; clicking the readout switches it), `length_decimals`, `angle_decimals`, `step_values` (default false: Up/Down and the wheel step a plain number in a focused value field), `theme` (`dark`, `light`, `system` or a theme file's id: a built-in one such as `gruvbox-dark`, or an imported one; the reply's `theme_ids` lists them), `theme_import` (a `solidcraft-theme/1` file's JSON or text: adds the theme and turns it on; the reply's `theme_imported` is its id), `theme_remove` (an imported theme's id), `theme_export: true` (the reply's `theme_file` is the theme on now as a complete file; see [colour themes](book/src/guide/ui-tour.md#colour-themes)), `language` (`en`, `ja`, `de`, `fr`, `ko`, `ms`, `ru`, `uk`, `zh`; see [localization](localization.md)), `ui_scale`, `ui_font` (an installed font family or a font file for the interface; empty for the built-in font), `up_axis` (`z`, `y`), `offer_stand_up`, `extrude_auto_to_object` (default false: in the Extrude dialog, with a profile picked, a face, vertex or parallel plane picked off its plane switches the extent to To Object; it applies to Extrude dialogs opened afterwards), `hole_snaps` (default false: a Single hole snaps to its face's middle and round edges' centres), `hole_moves` (default false: a placed Single hole has a drag handle (`hole:<n>`), and a pick on a face that has a hole moves it there), `color_vision` (`off` (default), `protan`, `deutan`, `tritan`: colour vision modes, #778), `check_updates` (default true; [updates](book/src/guide/updates.md)); `open` (a page: General, Interface, Design, Navigation, Keyboard Shortcuts, Sketch, Graphics, AI, Plugins; Shortcuts, Assistant and Sketch & selection are aliases, and the former Selection page opens Sketch) opens the Preferences dialog there; `button`: `ok`, `cancel`, `apply`, `defaults`; `stand_up: true` stands up a just-opened Y-up file, `stand_up: false` leaves it as it is ("Leave it": the offer closes and `offer_stand_up` stays on); the offer's buttons are the handles `stand_up:stand`, `stand_up:leave` and `stand_up:never` | sets preferences (kept between runs), returns them all plus `dialog` (the open page or null), `dark` and `stand_up_offer` || `ui.capture` | `action?`: `capture`, `revert`, `cancel` | answers the Capture Position question (asked when a command starts or the design is saved while components were moved without capturing); without `action`, what waits || `ui.window` | `action`: minimize, maximize, restore, toggle, close | what the title bar's caption buttons do (on Windows and Linux the application bar is the title bar); close asks about unsaved designs first || `ui.agent_cursor` | `show` (bool), `speed`: a number from 1 to 5 (times the normal speed) or `"instant"` (no animation: the command runs at once and the pointer jumps to where it acted), `follow_camera` (bool); all optional | the settings. While the cursor is shown, `engine.execute` first glides to the command's toolbar button and to each pick, then runs and replies; later requests wait their turn. The pointer shows the command's localized name, including commands inside a closed toolbar group; an animated batch names each command it visits. It also follows the pointer input sent with `ui.move`, `ui.click`, `ui.drag` and `ui.scroll`, as each event reaches the app, and a press leaves a ripple. `"animate": false` on a call skips it |diff --git a/vendor/README.md b/vendor/README.mdindex dc6396495e..a1655b908d 100644--- a/vendor/README.md+++ b/vendor/README.md@@ -276,6 +276,8 @@ Original package sources from https://github.com/emilk/egui/tree/0.36.2/crates/ewith both original licence texts retained. No images or bundled documentation are copied.SolidCraft changes:+- `src/setup.rs`, `src/lib.rs`: let a named adapter selector defer to the normal wgpu+ request when the requested card is unavailable or incompatible with the window surface.- `src/lib.rs`: use 1x MSAA on the selected OpenGL adapter before creating pipelines,exposing the effective sample count so host paint callbacks can match it.- `src/winit.rs`: use that same effective count for depth and resolve attachments.diff --git a/vendor/egui-wgpu/src/lib.rs b/vendor/egui-wgpu/src/lib.rsindex 44d4cbc3d4..089aeaeea6 100644--- a/vendor/egui-wgpu/src/lib.rs+++ b/vendor/egui-wgpu/src/lib.rs@@ -335,17 +335,23 @@ impl RenderState {request_adapter(instance, power_preference, compatible_surface, &[]).await}#[cfg(not(target_arch = "wasm32"))]- if let Some(native_adapter_selector) = _native_adapter_selector {- native_adapter_selector(&available_adapters, compatible_surface)- .map_err(WgpuError::CustomNativeAdapterSelectionError)- } else {- request_adapter(- instance,- power_preference,- compatible_surface,- &available_adapters,- )- .await+ {+ let selected = _native_adapter_selector+ .map(|select| select(&available_adapters, compatible_surface))+ .transpose()+ .map_err(WgpuError::CustomNativeAdapterSelectionError)?+ .flatten();+ if let Some(adapter) = selected {+ Ok(adapter)+ } else {+ request_adapter(+ instance,+ power_preference,+ compatible_surface,+ &available_adapters,+ )+ .await+ }}}?;diff --git a/vendor/egui-wgpu/src/setup.rs b/vendor/egui-wgpu/src/setup.rsindex f3a881ca05..4f0847e6ad 100644--- a/vendor/egui-wgpu/src/setup.rs+++ b/vendor/egui-wgpu/src/setup.rs@@ -151,8 +151,9 @@ impl From<WgpuSetupExisting> for WgpuSetup {////// This can be used for fully custom adapter selection./// If available, `wgpu::Surface` is passed to allow checking for surface compatibility.+/// Return `Ok(None)` to use the normal wgpu adapter request.pub type NativeAdapterSelectorMethod = Arc<- dyn Fn(&[wgpu::Adapter], Option<&wgpu::Surface<'_>>) -> Result<wgpu::Adapter, String>+ dyn Fn(&[wgpu::Adapter], Option<&wgpu::Surface<'_>>) -> Result<Option<wgpu::Adapter>, String>+ Send+ Sync,>;@@ -189,13 +190,13 @@ pub struct WgpuSetupCreateNew {/// `eframe` 's winit & web integrations will attempt to fill the display handle automatically if it is left empty.pub display_handle: Option<Box<dyn EguiDisplayHandle>>,- /// Power preference for the adapter if [`Self::native_adapter_selector`] is not set or targeting web.+ /// Power preference when the selector is absent, returns `Ok(None)`, or when targeting web.pub power_preference: wgpu::PowerPreference,/// Optional selector for native adapters.////// This field has no effect when targeting web!- /// Otherwise, if set [`Self::power_preference`] is ignored and the adapter is instead selected by this method.+ /// Otherwise, this method can select an adapter or return `Ok(None)` to request one with [`Self::power_preference`]./// Note that [`Self::instance_descriptor`]'s [`wgpu::InstanceDescriptor::backends`]/// are still used to filter the adapter enumeration in the first place.///