Merge pull request #8086 from dotCooCoo/feat/low-latency-drawing

Performance: Low-Latency Drawing preference presents without vsync, capped at 240 fps
This commit is contained in:
BFlat
2026-11-18 10:15:17 +07:00
committed by GitHub
38 changed files with 276 additions and 18 deletions
+10
View File
@@ -43,6 +43,16 @@ impl eframe::App for App {
/// Restore the borderless caption, apply platform menu and pen input, and hand the frame to the
/// app's raw-input hook while the keyboard user is unconfined.
fn raw_input_hook(&mut self, ctx: &egui::Context, raw: &mut egui::RawInput) {
// Without vsync, a main-window frame starts no sooner than the minimum interval after the
// last one. eframe runs this hook once per frame, shown or not, before egui reads the input.
// The frame's time moves on by the wait, and the hang report's frame time starts after it.
if raw.viewport_id == egui::ViewportId::ROOT {
if let Some(wait) = super::presentation::frame_wait(self.min_frame, self.last_frame_began.map(|t| t.elapsed())) {
std::thread::sleep(wait);
raw.time = raw.time.map(|time| time + wait.as_secs_f64());
}
self.last_frame_began = Some(std::time::Instant::now());
}
let _timed = BEACON.enter_timed(Stage::Input);
self.frame_start = Some(std::time::Instant::now());
// winit gives the window its caption back when it changes the window's flags (maximize,
+20 -3
View File
@@ -142,6 +142,11 @@ struct App {
display_profile: display_profile::Reader,
/// When this frame's input hook started, for the hang report's frame times (`hang_watch`).
frame_start: Option<std::time::Instant>,
/// The shortest time between the starts of two frames, while the window presents without vsync
/// ([`presentation::min_frame_interval`]).
min_frame: Option<std::time::Duration>,
/// When the last frame started, after its wait for [`Self::min_frame`].
last_frame_began: Option<std::time::Instant>,
}
/// `vectorcraft --help`. Headless work (convert, run, MCP) is `vectorcraft-cli`'s.
@@ -365,6 +370,10 @@ fn main() -> std::process::ExitCode {
let saved_window = saved.as_ref().and_then(|ui| ui.window);
#[cfg(feature = "wgpu")]
let gpu_pref = saved.as_ref().and_then(|ui| ui.engine_prefs.get("gpuPreference")).and_then(serde_json::Value::as_str);
// Preferences › Performance › Low-Latency Drawing; anything but `true` in the file is off.
#[cfg(feature = "wgpu")]
let low_latency_drawing =
saved.as_ref().and_then(|ui| ui.engine_prefs.get("lowLatencyDrawing")).and_then(serde_json::Value::as_bool).unwrap_or(false);
#[cfg(feature = "wgpu")]
let power_env = eframe::wgpu::PowerPreference::from_env();
#[cfg(feature = "wgpu")]
@@ -458,10 +467,11 @@ fn main() -> std::process::ExitCode {
let mut options = options;
// One frame queued, not two: the canvas is rasterized on the CPU and the GPU only
// composites it, so the window answers the pointer a frame sooner (#444).
// `--present-mode` and `--frame-latency` change it for a launch (`presentation`).
options.wgpu_options.surface = presentation.apply(eframe::egui_wgpu::SurfaceConfig::LOW_LATENCY);
// `--present-mode` and `--frame-latency` change it for a launch, and Low-Latency Drawing
// asks for no vsync when neither sets the mode (`presentation`).
options.wgpu_options.surface = presentation.apply(eframe::egui_wgpu::SurfaceConfig::LOW_LATENCY, low_latency_drawing);
// What the app asks for: the driver picks novsync's mode and may clamp the latency.
log::info!("requested window surface: {}", presentation::describe(&options.wgpu_options.surface, &presentation));
log::info!("requested window surface: {}", presentation::describe(&options.wgpu_options.surface, &presentation, low_latency_drawing));
// Only adapters that can show the window, in the order `gpu` gives (#306, #502).
if let eframe::egui_wgpu::WgpuSetup::CreateNew(create) = &mut options.wgpu_options.wgpu_setup {
create.native_adapter_selector = Some(gpu::selector(power, displays, compositor, left_out.adapters.clone(), startup.clone()));
@@ -508,6 +518,11 @@ fn main() -> std::process::ExitCode {
// For the hang report (`hang_watch`).
#[cfg(feature = "wgpu")]
let requested_surface = options.wgpu_options.surface;
// Without vsync, frames start at most 240 times a second (`presentation`).
#[cfg(feature = "wgpu")]
let min_frame = presentation::min_frame_interval(&requested_surface);
#[cfg(not(feature = "wgpu"))]
let min_frame = None;
// A panic that ends the window (egui-wgpu's own, #502) is caught here: never a crash.
let run = |options: eframe::NativeOptions, app_creator: eframe::AppCreator<'_>| {
#[cfg(target_os = "linux")]
@@ -694,6 +709,8 @@ fn main() -> std::process::ExitCode {
monitors_listed: None,
display_profile: Default::default(),
frame_start: None,
min_frame,
last_frame_began: None,
}))
}),
)
+122 -15
View File
@@ -6,9 +6,17 @@
//! frames the swap chain may queue, 1 to 3. Unset, the app keeps its own surface settings. A flag
//! overrides its variable; a value that isn't one of these stops the app with a message, as
//! `--control` does. A launch that sets either one runs as its own app, as with `--new-instance`.
//! The surface the app asks for is logged at start-up.
//! Preferences › Performance › Low-Latency Drawing (`lowLatencyDrawing`, off by default, read at
//! start-up) asks for `novsync` when neither the flag nor the variable sets the mode. Whenever the
//! surface presents without vsync, frames start at most 240 times a second. The surface the app
//! asks for is logged at start-up, with where its present mode came from.
use std::ffi::OsString;
use std::time::Duration;
/// The most frames a second the window draws while it presents without vsync.
#[cfg(feature = "wgpu")]
pub const UNSYNCED_FRAME_CAP: u32 = 240;
/// A present mode the command line or the environment can ask for.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
@@ -96,25 +104,44 @@ impl Overrides {
Ok(Self { mode, latency })
}
/// `surface` with the overrides applied.
/// `surface` with the overrides applied. With Low-Latency Drawing on (`low_latency_drawing`) and
/// no present mode override, the mode is `novsync`.
#[cfg(feature = "wgpu")]
pub fn apply(&self, surface: eframe::egui_wgpu::SurfaceConfig) -> eframe::egui_wgpu::SurfaceConfig {
pub fn apply(&self, surface: eframe::egui_wgpu::SurfaceConfig, low_latency_drawing: bool) -> eframe::egui_wgpu::SurfaceConfig {
use eframe::wgpu::PresentMode;
let present_mode = match self.mode {
Some(Mode::Fifo) => PresentMode::Fifo,
Some(Mode::AutoVsync) => PresentMode::AutoVsync,
Some(Mode::NoVsync) => PresentMode::AutoNoVsync,
None if low_latency_drawing => PresentMode::AutoNoVsync,
None => surface.present_mode,
};
eframe::egui_wgpu::SurfaceConfig { present_mode, desired_maximum_frame_latency: self.latency.or(surface.desired_maximum_frame_latency) }
}
}
/// The present mode and frame latency `surface` asks for, for the start-up log:
/// "autovsync, frame latency 1", with "(override)"
/// after a value a flag or variable set.
/// The shortest time between the starts of two frames on `surface`: `None` with vsync, where the
/// display paces the frames, and 1/[`UNSYNCED_FRAME_CAP`] of a second without it.
#[cfg(feature = "wgpu")]
pub fn describe(surface: &eframe::egui_wgpu::SurfaceConfig, overrides: &Overrides) -> String {
pub fn min_frame_interval(surface: &eframe::egui_wgpu::SurfaceConfig) -> Option<Duration> {
use eframe::wgpu::PresentMode;
match surface.present_mode {
PresentMode::AutoNoVsync | PresentMode::Immediate | PresentMode::Mailbox => Some(Duration::from_secs(1) / UNSYNCED_FRAME_CAP),
PresentMode::AutoVsync | PresentMode::Fifo | PresentMode::FifoRelaxed => None,
}
}
/// How long a frame waits before it starts, `since_last` after the previous frame started, so that
/// frames start at least `min` apart. `None`: no wait (no cap, the first frame, or `min` has passed).
pub fn frame_wait(min: Option<Duration>, since_last: Option<Duration>) -> Option<Duration> {
min?.checked_sub(since_last?).filter(|wait| !wait.is_zero())
}
/// The present mode and frame latency `surface` asks for, for the start-up log:
/// "autovsync, frame latency 1", with "(override)" after a value a flag or variable set, and
/// "(preference)" after a present mode Low-Latency Drawing set.
#[cfg(feature = "wgpu")]
pub fn describe(surface: &eframe::egui_wgpu::SurfaceConfig, overrides: &Overrides, low_latency_drawing: bool) -> String {
use eframe::wgpu::PresentMode;
let mode = match surface.present_mode {
PresentMode::AutoVsync => "autovsync",
@@ -126,7 +153,8 @@ pub fn describe(surface: &eframe::egui_wgpu::SurfaceConfig, overrides: &Override
};
let latency = surface.desired_maximum_frame_latency.map_or("default".to_string(), |n| n.to_string());
let tag = |set: bool| if set { " (override)" } else { "" };
format!("{mode}{}, frame latency {latency}{}", tag(overrides.mode.is_some()), tag(overrides.latency.is_some()))
let mode_tag = if overrides.mode.is_none() && low_latency_drawing { " (preference)" } else { tag(overrides.mode.is_some()) };
format!("{mode}{mode_tag}, frame latency {latency}{}", tag(overrides.latency.is_some()))
}
#[cfg(test)]
@@ -224,20 +252,99 @@ mod tests {
use eframe::wgpu::PresentMode;
let app = SurfaceConfig::LOW_LATENCY;
// No override: the surface the app asks for is unchanged.
assert_eq!(Overrides::default().apply(app), app);
assert_eq!(Overrides::default().apply(app, false), app);
let latency = Overrides { mode: None, latency: Some(2) };
let s = latency.apply(app);
let s = latency.apply(app, false);
assert_eq!((s.present_mode, s.desired_maximum_frame_latency), (PresentMode::AutoVsync, Some(2)));
assert_eq!(describe(&s, &latency), "autovsync, frame latency 2 (override)");
assert_eq!(describe(&s, &latency, false), "autovsync, frame latency 2 (override)");
let fifo = Overrides { mode: Some(Mode::Fifo), latency: None };
let s = fifo.apply(app);
let s = fifo.apply(app, false);
assert_eq!((s.present_mode, s.desired_maximum_frame_latency), (PresentMode::Fifo, app.desired_maximum_frame_latency));
// Never a mode the driver may lack: no vsync lets wgpu fall back by support.
let novsync = Overrides { mode: Some(Mode::NoVsync), latency: Some(3) };
let s = novsync.apply(app);
let s = novsync.apply(app, false);
assert_eq!((s.present_mode, s.desired_maximum_frame_latency), (PresentMode::AutoNoVsync, Some(3)));
assert_eq!(describe(&s, &novsync), "novsync (override), frame latency 3 (override)");
assert_eq!(describe(&s, &novsync, false), "novsync (override), frame latency 3 (override)");
let unset = SurfaceConfig { present_mode: PresentMode::Fifo, desired_maximum_frame_latency: None };
assert_eq!(describe(&unset, &Overrides::default()), "fifo, frame latency default");
assert_eq!(describe(&unset, &Overrides::default(), false), "fifo, frame latency default");
}
/// Low-Latency Drawing alone asks for no vsync, through wgpu's fallback by support and never an
/// explicit Immediate or Mailbox; off, the app's surface is exactly its own.
#[cfg(feature = "wgpu")]
#[test]
fn low_latency_drawing_alone_presents_without_vsync_and_off_keeps_the_app_surface() {
use eframe::egui_wgpu::SurfaceConfig;
use eframe::wgpu::PresentMode;
let app = SurfaceConfig::LOW_LATENCY;
let none = Overrides::default();
assert_eq!(none.apply(app, false), app);
let s = none.apply(app, true);
assert_eq!(s.present_mode, PresentMode::AutoNoVsync);
assert_eq!(s.desired_maximum_frame_latency, app.desired_maximum_frame_latency);
let frames = app.desired_maximum_frame_latency.map_or("default".to_string(), |n| n.to_string());
assert_eq!(describe(&s, &none, true), format!("novsync (preference), frame latency {frames}"));
// A latency override still applies with the preference's mode.
let latency = Overrides { mode: None, latency: Some(2) };
let s = latency.apply(app, true);
assert_eq!((s.present_mode, s.desired_maximum_frame_latency), (PresentMode::AutoNoVsync, Some(2)));
assert_eq!(describe(&s, &latency, true), "novsync (preference), frame latency 2 (override)");
}
/// The flag and the variable each set the present mode over Low-Latency Drawing.
#[cfg(feature = "wgpu")]
#[test]
fn the_flag_and_the_variable_win_over_low_latency_drawing() {
use eframe::egui_wgpu::SurfaceConfig;
use eframe::wgpu::PresentMode;
let app = SurfaceConfig::LOW_LATENCY;
let flag = parse(&["--present-mode", "fifo"]).unwrap();
let s = flag.apply(app, true);
assert_eq!(s.present_mode, PresentMode::Fifo);
assert!(describe(&s, &flag, true).starts_with("fifo (override),"), "{}", describe(&s, &flag, true));
let var = Overrides::default().with_env(Some("autovsync".into()), None).unwrap();
let s = var.apply(app, true);
assert_eq!(s.present_mode, PresentMode::AutoVsync);
assert!(describe(&s, &var, true).starts_with("autovsync (override),"), "{}", describe(&s, &var, true));
// The flag wins over the variable, and both over the preference.
let both = parse(&["--present-mode=fifo"]).unwrap().with_env(Some("novsync".into()), None).unwrap();
assert_eq!(both.apply(app, true).present_mode, PresentMode::Fifo);
}
/// Frames start at most 240 times a second without vsync, from the preference or an override,
/// and the display paces them with vsync.
#[cfg(feature = "wgpu")]
#[test]
fn the_frame_cap_applies_only_without_vsync_at_240_frames_a_second() {
use eframe::egui_wgpu::SurfaceConfig;
use eframe::wgpu::PresentMode;
let app = SurfaceConfig::LOW_LATENCY;
let cap = Duration::from_secs(1) / 240;
assert_eq!(cap.as_nanos(), 4_166_666);
assert_eq!(min_frame_interval(&Overrides::default().apply(app, true)), Some(cap));
assert_eq!(min_frame_interval(&Overrides { mode: Some(Mode::NoVsync), latency: None }.apply(app, false)), Some(cap));
assert_eq!(min_frame_interval(&Overrides::default().apply(app, false)), None);
assert_eq!(min_frame_interval(&Overrides { mode: Some(Mode::Fifo), latency: None }.apply(app, true)), None);
for (mode, capped) in [
(PresentMode::Immediate, true),
(PresentMode::Mailbox, true),
(PresentMode::AutoNoVsync, true),
(PresentMode::Fifo, false),
(PresentMode::FifoRelaxed, false),
(PresentMode::AutoVsync, false),
] {
let s = SurfaceConfig { present_mode: mode, desired_maximum_frame_latency: Some(1) };
assert_eq!(min_frame_interval(&s).is_some(), capped, "{mode:?}");
}
}
#[test]
fn a_frame_waits_out_the_rest_of_the_minimum_interval() {
let min = Some(Duration::from_millis(4));
assert_eq!(frame_wait(min, Some(Duration::from_millis(1))), Some(Duration::from_millis(3)));
assert_eq!(frame_wait(min, Some(Duration::from_millis(4))), None);
assert_eq!(frame_wait(min, Some(Duration::from_millis(9))), None);
assert_eq!(frame_wait(min, None), None, "the first frame starts at once");
assert_eq!(frame_wait(None, Some(Duration::ZERO)), None, "no cap with vsync");
}
}
+2
View File
@@ -368,6 +368,8 @@ pub const PREF_SPECS: &[PrefSpec] = &[
p!("gpuPerformance", "Performance", "GPU Performance", "GPU Performance", bool),
p!("animatedZoom", "Performance", "GPU Performance", "Animated Zoom", bool),
p!("gpuPreference", "Performance", "GPU Performance", "Graphics Processor", choice(GPU_PREFERENCES)),
// Read by the desktop app at startup: the window presents without vsync, capped at 240 fps (#6013).
p!("lowLatencyDrawing", "Performance", "GPU Performance", "Low-Latency Drawing", bool),
p!("historyStates", "Performance", "", "History States", int(5, 1000)),
p!("realTimeDrawing", "Performance", "", "Real-time Drawing and Editing", bool),
p!("renderThreads", "Performance", "", "Render Threads (-1 = Automatic)", int(-1, 64)),
+5
View File
@@ -214,6 +214,10 @@ pub struct Prefs {
/// runs on: a Wayland compositor may not show frames from another GPU (#502). Single-GPU
/// machines are unaffected.
pub gpu_preference: String,
/// The desktop app's window presents without vsync, with frames capped at 240 a second (#6013).
/// Read at startup (it takes effect after a restart); `--present-mode` and
/// `VECTORCRAFT_PRESENT_MODE` take precedence over it.
pub low_latency_drawing: bool,
pub history_states: u32,
pub real_time_drawing: bool,
/// Rasterizer worker threads; -1 = automatic.
@@ -503,6 +507,7 @@ impl Default for Prefs {
gpu_performance: true,
animated_zoom: true,
gpu_preference: s("automatic"),
low_latency_drawing: false,
history_states: 500,
real_time_drawing: true,
render_threads: -1,
+31
View File
@@ -447,6 +447,37 @@ fn gpu_preference_defaults_to_automatic_and_validates() {
assert_eq!(s.prefs.gpu_preference, "automatic");
}
/// Performance › Low-Latency Drawing (#6013): off by default and for preference files written
/// before it, a boolean only, kept through a save/load round trip, listed under Performance and
/// reset with it.
#[test]
fn low_latency_drawing_defaults_off_and_takes_only_a_boolean() {
let mut s = Session::new();
assert!(!s.prefs.low_latency_drawing);
assert_eq!(s.execute("prefs.get", &json!({"key": "lowLatencyDrawing"})).unwrap(), json!(false));
s.execute("prefs.set", &json!({"key": "lowLatencyDrawing", "value": true})).unwrap();
assert!(s.prefs.low_latency_drawing);
for bad in [json!(1), json!(null), json!("on"), json!("yes"), json!([true])] {
assert!(s.execute("prefs.set", &json!({"key": "lowLatencyDrawing", "value": bad})).is_err(), "{bad}");
assert!(s.prefs.low_latency_drawing);
}
// Booleans may be given as "true" and "false", as for every boolean preference.
s.execute("prefs.set", &json!({"key": "lowLatencyDrawing", "value": "false"})).unwrap();
assert!(!s.prefs.low_latency_drawing);
s.execute("prefs.set", &json!({"key": "lowLatencyDrawing", "value": "true"})).unwrap();
assert_eq!(s.prefs.to_json()["lowLatencyDrawing"], json!(true));
let back: Prefs = serde_json::from_value(s.prefs.to_json()).unwrap();
assert!(back.low_latency_drawing);
let old: Prefs = serde_json::from_value(json!({"gpuPerformance": true})).unwrap();
assert!(!old.low_latency_drawing);
let l = s.execute("prefs.list", &json!({})).unwrap();
let row = l.as_array().unwrap().iter().find(|e| e["key"] == "lowLatencyDrawing").unwrap().clone();
assert_eq!(row["category"], "Performance");
assert_eq!(row["label"], "Low-Latency Drawing");
s.execute("prefs.reset", &json!({"category": "Performance"})).unwrap();
assert!(!s.prefs.low_latency_drawing);
}
/// Performance › Linux Display Server (#1151): automatic by default, X11 by value or label, and
/// anything else is an error that changes nothing.
#[test]
+1
View File
@@ -5414,6 +5414,7 @@ lighting Light Светлина
@msg missing panel layout липсващо оформление на панели
@msg unsupported native docking operation неподдържана вградена операция за скачване
Linux Display Server Дисплейен сървър за Linux
Low-Latency Drawing Рисуване с ниско забавяне
X11 (XWayland) When a Pen Is Attached X11 (XWayland) при свързана писалка
If a drawing tablet's pen doesn't draw, choose an X11 (XWayland) option. Ако писалката на графичния таблет не рисува, изберете опция X11 (XWayland).
X11 (XWayland) X11 (XWayland)
Can't render this file because it is too large.
+1
View File
@@ -4081,6 +4081,7 @@ theme Appearance Izgled
Scroll Sideways with Cmd/Ctrl + Wheel Pomjeraj vodoravno uz Cmd/Ctrl + točkić miša
Scrub Numeric Fields by Dragging Mijenjaj numerička polja prevlačenjem
Linux Display Server Linux server prikaza
Low-Latency Drawing Crtanje s malim kašnjenjem
Print Preview Pregled štampanja
Print Setup Podešavanje štampe
Bitmap Bitmapa
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -2502,6 +2502,7 @@ digits Malayalam Malaiàlam
Linked Files Fitxers enllaçats
Links Enllaços
Linux Display Server Servidor de pantalla de Linux
Low-Latency Drawing Dibuix de baixa latència
Liquify Liquifica
List Data Sets Llista els conjunts de dades
List Folder Llista la carpeta
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -4183,6 +4183,7 @@ theme Appearance Motiv
Scroll Sideways with Cmd/Ctrl + Wheel Posouvat vodorovně kolečkem s Cmd/Ctrl
Scrub Numeric Fields by Dragging Měnit číselné hodnoty tažením
Linux Display Server Zobrazovací server Linuxu
Low-Latency Drawing Kreslení s nízkou latencí
Print Preview Náhled tisku
Print Setup Nastavení tisku
Bitmap Bitmapa
Can't render this file because it is too large.
+1
View File
@@ -6596,6 +6596,7 @@ theme Appearance Udseende
Scroll Sideways with Cmd/Ctrl + Wheel Rul vandret med Cmd/Ctrl + musehjul
Scrub Numeric Fields by Dragging Juster numeriske felter ved at trække
Linux Display Server Linux-visningsserver
Low-Latency Drawing Tegning med lav latens
Print Preview Udskriftsvisning
Print Setup Udskriftsopsætning
Bitmap Bitmap
Can't render this file because it is too large.
+1
View File
@@ -5828,6 +5828,7 @@ lighting Light Licht
@msg missing panel layout Bedienfeldanordnung fehlt
@msg unsupported native docking operation Nicht unterstützte native Docking-Operation
Linux Display Server Linux-Anzeigeserver
Low-Latency Drawing Zeichnen mit geringer Latenz
X11 (XWayland) When a Pen Is Attached X11 (XWayland), wenn ein Stift angeschlossen ist
If a drawing tablet's pen doesn't draw, choose an X11 (XWayland) option. Wenn der Stift eines Grafiktabletts nicht zeichnet, wählen Sie eine Option mit X11 (XWayland).
X11 (XWayland) X11 (XWayland)
Can't render this file because it is too large.
+1
View File
@@ -5702,6 +5702,7 @@ digits Malayalam Μαλαγιάλαμ
@msg missing panel layout λείπει η διάταξη πινάκων
@msg unsupported native docking operation μη υποστηριζόμενη εγγενής λειτουργία σύνδεσης πινάκων
Linux Display Server Διακομιστής οθόνης Linux
Low-Latency Drawing Σχεδίαση χαμηλής καθυστέρησης
Ruler Origin Αρχή χαράκων
Reset Ruler Origin Επαναφορά αρχής χαράκων
@msg the compressed file unpacks to more than VectorCraft reads ({_1} MB of document, {_2} MB per image) το αποσυμπιεσμένο αρχείο υπερβαίνει τα όρια ανάγνωσης του VectorCraft ({_1} MB ανά έγγραφο, {_2} MB ανά εικόνα)
Can't render this file because it is too large.
+1
View File
@@ -5853,6 +5853,7 @@ lighting Light Luz
@msg missing panel layout Falta la distribución de paneles
@msg unsupported native docking operation Operación nativa de anclaje no admitida
Linux Display Server Servidor de pantalla de Linux
Low-Latency Drawing Dibujo de baja latencia
X11 (XWayland) When a Pen Is Attached X11 (XWayland) cuando hay un lápiz conectado
If a drawing tablet's pen doesn't draw, choose an X11 (XWayland) option. Si el lápiz de una tableta digitalizadora no dibuja, elige una opción X11 (XWayland).
X11 (XWayland) X11 (XWayland)
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -4107,6 +4107,7 @@ theme Appearance Ulkoasu
Scroll Sideways with Cmd/Ctrl + Wheel Vieritä vaakasuunnassa Cmd/Ctrl + hiiren rullalla
Scrub Numeric Fields by Dragging Muuta numerokenttiä vetämällä
Linux Display Server Linuxin näyttöpalvelin
Low-Latency Drawing Pienen viiveen piirto
Print Preview Tulostuksen esikatselu
Print Setup Tulostusasetukset
Bitmap Bittikartta
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -5832,6 +5832,7 @@ lighting Light Lumière
@msg missing panel layout Disposition des panneaux manquante
@msg unsupported native docking operation Opération native d’ancrage non prise en charge
Linux Display Server Serveur d’affichage Linux
Low-Latency Drawing Dessin à faible latence
X11 (XWayland) When a Pen Is Attached X11 (XWayland) quand un stylet est branché
If a drawing tablet's pen doesn't draw, choose an X11 (XWayland) option. Si le stylet d’une tablette graphique ne dessine pas, choisissez une option X11 (XWayland).
X11 (XWayland) X11 (XWayland)
Can't render this file because it is too large.
+1
View File
@@ -2049,6 +2049,7 @@
Linked Files લિંક કરેલી ફાઇલો
Links લિંક્સ
Linux Display Server Linux ડિસ્પ્લે સર્વર
Low-Latency Drawing ઓછા વિલંબવાળું ડ્રોઇંગ
Liquify લિક્વિફાઇ
List Data Sets ડેટા સેટની યાદી
List Folder ફોલ્ડરની યાદી
Can't render this file because it contains an unexpected character in line 72 and column 5.
+1
View File
@@ -2748,6 +2748,7 @@ antiAlias Sharp शार्प
Linked Files लिंक्ड फ़ाइलें
Links लिंक
Linux Display Server Linux डिस्प्ले सर्वर
Low-Latency Drawing कम विलंब वाली ड्राइंग
Liquify लिक्विफ़ाई
List Data Sets सूची डेटा सेट
List Folder सूची फ़ोल्डर
Can't render this file because it is too large.
+1
View File
@@ -2502,6 +2502,7 @@ file-filter Templates Sablonok
Linked File Not Found A csatolt fájl nem található
Links Csatolások
Linux Display Server Linuxos megjelenítőszerver
Low-Latency Drawing Alacsony késleltetésű rajzolás
Liquify Folyékony torzítás
List Data Sets Adatkészletek listázása
List Folder Mappa listázása
Can't render this file because it is too large.
+1
View File
@@ -3845,6 +3845,7 @@ theme Appearance Tampilan
Scroll Sideways with Cmd/Ctrl + Wheel Gulir horizontal dengan Cmd/Ctrl + roda mouse
Scrub Numeric Fields by Dragging Atur nilai kolom numerik dengan menyeret
Linux Display Server Server tampilan Linux
Low-Latency Drawing Penggambaran latensi rendah
Print Preview Pratinjau cetak
Print Setup Pengaturan cetak
Bitmap Bitmap
Can't render this file because it contains an unexpected character in line 2513 and column 5.
+1
View File
@@ -5881,6 +5881,7 @@ lighting Light Luce
@msg missing panel layout Disposizione dei pannelli mancante
@msg unsupported native docking operation Operazione nativa di ancoraggio non supportata
Linux Display Server Server di visualizzazione Linux
Low-Latency Drawing Disegno a bassa latenza
X11 (XWayland) When a Pen Is Attached X11 (XWayland) quando è collegata una penna
If a drawing tablet's pen doesn't draw, choose an X11 (XWayland) option. Se la penna di una tavoletta grafica non disegna, scegli un'opzione X11 (XWayland).
X11 (XWayland) X11 (XWayland)
Can't render this file because it is too large.
+1
View File
@@ -5924,6 +5924,7 @@ lighting Light ライト
@msg missing panel layout パネル配置がありません
@msg unsupported native docking operation ネイティブドッキング操作は未対応です
Linux Display Server Linux ディスプレイサーバー
Low-Latency Drawing 低遅延描画
X11 (XWayland) When a Pen Is Attached ペン接続時は X11 (XWayland)
If a drawing tablet's pen doesn't draw, choose an X11 (XWayland) option. ペンタブレットのペンで描画できない場合は、X11 (XWayland) のいずれかを選択してください。
X11 (XWayland) X11 (XWayland)
Can't render this file because it is too large.
+1
View File
@@ -5938,6 +5938,7 @@ theme Appearance იერსახე
Scroll Sideways with Cmd/Ctrl + Wheel ჰორიზონტალური გადაადგილება Cmd/Ctrl + ბორბლით
Scrub Numeric Fields by Dragging რიცხვითი ველების შეცვლა გადათრევით
Linux Display Server Linux-ის ეკრანის სერვერი
Low-Latency Drawing დაბალი დაყოვნების ხატვა
Print Preview ნახვა ამობეჭდვამდე
Print Setup ბეჭდვის მომართვა
Bitmap ბიტმაპი
Can't render this file because it is too large.
+1
View File
@@ -5845,6 +5845,7 @@ lighting Light 광원
@msg missing panel layout 패널 레이아웃이 없습니다
@msg unsupported native docking operation 지원되지 않는 기본 도킹 작업
Linux Display Server Linux 디스플레이 서버
Low-Latency Drawing 저지연 그리기
X11 (XWayland) When a Pen Is Attached 펜 연결 시 X11 (XWayland)
If a drawing tablet's pen doesn't draw, choose an X11 (XWayland) option. 드로잉 태블릿의 펜으로 그려지지 않으면 X11 (XWayland) 옵션을 선택하세요.
X11 (XWayland) X11 (XWayland)
Can't render this file because it is too large.
+1
View File
@@ -4467,6 +4467,7 @@ theme Appearance Vormgeving
Scroll Sideways with Cmd/Ctrl + Wheel Horizontaal scrollen met Cmd/Ctrl + muiswiel
Scrub Numeric Fields by Dragging Numerieke velden aanpassen door te slepen
Linux Display Server Linux-weergaveserver
Low-Latency Drawing Tekenen met lage latentie
Print Preview Afdrukvoorbeeld
Print Setup Afdrukinstellingen
Bitmap Bitmap
Can't render this file because it is too large.
+1
View File
@@ -4046,6 +4046,7 @@ theme Appearance Wygląd
Scroll Sideways with Cmd/Ctrl + Wheel Przewijaj w poziomie kółkiem z Cmd/Ctrl
Scrub Numeric Fields by Dragging Zmieniaj pola liczbowe przeciąganiem
Linux Display Server Serwer wyświetlania Linux
Low-Latency Drawing Rysowanie z niskim opóźnieniem
Print Preview Podgląd wydruku
Print Setup Ustawienia wydruku
Bitmap Bitmapa
Can't render this file because it is too large.
+1
View File
@@ -5899,6 +5899,7 @@ liquify-list-end {0}, {1} {0} e {1}
Right Diagonal Diagonal Direita
Left Diagonal Diagonal Esquerda
Linux Display Server Servidor de Exibição do Linux
Low-Latency Drawing Desenho de Baixa Latência
X11 (XWayland) When a Pen Is Attached X11 (XWayland) Quando Houver uma Caneta Conectada
If a drawing tablet's pen doesn't draw, choose an X11 (XWayland) option. Se a caneta de uma mesa digitalizadora não desenhar, escolha uma opção X11 (XWayland).
X11 (XWayland) X11 (XWayland)
Can't render this file because it is too large.
+1
View File
@@ -5877,6 +5877,7 @@ lighting Light Свет
@msg missing panel layout Отсутствует расположение панелей
@msg unsupported native docking operation Неподдерживаемая собственная операция прикрепления
Linux Display Server Дисплейный сервер Linux
Low-Latency Drawing Рисование с низкой задержкой
X11 (XWayland) When a Pen Is Attached X11 (XWayland) при подключенном пере
If a drawing tablet's pen doesn't draw, choose an X11 (XWayland) option. Если перо графического планшета не рисует, выберите вариант X11 (XWayland).
X11 (XWayland) X11 (XWayland)
Can't render this file because it is too large.
+1
View File
@@ -5755,6 +5755,7 @@ lighting Light Ljus
@msg missing panel layout panellayout saknas
@msg unsupported native docking operation inbyggd dockningsåtgärd som inte stöds
Linux Display Server Linux-skärmserver
Low-Latency Drawing Ritning med låg latens
X11 (XWayland) When a Pen Is Attached X11 (XWayland) när en penna är ansluten
If a drawing tablet's pen doesn't draw, choose an X11 (XWayland) option. Om ritplattans penna inte ritar väljer du ett X11 (XWayland)-alternativ.
X11 (XWayland) X11 (XWayland)
Can't render this file because it is too large.
+1
View File
@@ -5613,6 +5613,7 @@ lighting Light Işık
@msg missing panel layout eksik panel düzeni
@msg unsupported native docking operation desteklenmeyen yerel yerleştirme işlemi
Linux Display Server Linux Görüntü Sunucusu
Low-Latency Drawing Düşük Gecikmeli Çizim
X11 (XWayland) X11 (XWayland)
Ruler Origin Cetvelin Kökeni
Reset Ruler Origin Cetvel Başlangıç Noktasını Sıfırla
Can't render this file because it is too large.
+1
View File
@@ -5861,6 +5861,7 @@ lighting Light Світло
@msg missing panel layout Відсутнє розташування панелей
@msg unsupported native docking operation Непідтримувана власна операція прикріплення
Linux Display Server Дисплейний сервер Linux
Low-Latency Drawing Малювання з низькою затримкою
X11 (XWayland) When a Pen Is Attached X11 (XWayland), коли підключено перо
If a drawing tablet's pen doesn't draw, choose an X11 (XWayland) option. Якщо перо графічного планшета не малює, виберіть варіант X11 (XWayland).
X11 (XWayland) X11 (XWayland)
Can't render this file because it is too large.
+1
View File
@@ -2338,6 +2338,7 @@ digits Hindi Hindi
Linked File Not Found Không tìm thấy tệp liên kết
Links Liên kết
Linux Display Server Máy chủ hiển thị Linux
Low-Latency Drawing Vẽ độ trễ thấp
Liquify Lỏng hóa
List Data Sets Liệt kê tập dữ liệu
List Folder Liệt kê thư mục
Can't render this file because it contains an unexpected character in line 206 and column 5.
+1
View File
@@ -6138,6 +6138,7 @@ lighting Light 光源
Horizontal Guide 水平参考线
Move Guide to Layer 将参考线移至图层
Linux Display Server Linux 显示服务器
Low-Latency Drawing 低延迟绘图
X11 (XWayland) When a Pen Is Attached 连接手写笔时使用 X11 (XWayland)
If a drawing tablet's pen doesn't draw, choose an X11 (XWayland) option. 如果数位板的笔无法绘画,请选择一个 X11 (XWayland) 选项。
X11 (XWayland) X11 (XWayland)
Can't render this file because it is too large.
+1
View File
@@ -5974,6 +5974,7 @@ lighting Light 光源
Horizontal Guide 水平參考線
Move Guide to Layer 將參考線移至圖層
Linux Display Server Linux 顯示伺服器
Low-Latency Drawing 低延遲繪圖
X11 (XWayland) When a Pen Is Attached 連接觸控筆時使用 X11 (XWayland)
If a drawing tablet's pen doesn't draw, choose an X11 (XWayland) option. 如果繪圖板的筆無法繪圖,請選擇一個 X11 (XWayland) 選項。
X11 (XWayland) X11 (XWayland)
Can't render this file because it is too large.
+14
View File
@@ -72,6 +72,7 @@ fn settings() -> impl Iterator<Item = Setting> {
"appTitleBar" => APP_TITLE_BAR_SHOWN,
"linuxDisplayServer" => DISPLAY_SERVER_CHOICE,
"monitorProfileDisplay" => !cfg!(target_arch = "wasm32"),
"lowLatencyDrawing" => !cfg!(target_arch = "wasm32"),
_ => true,
};
let prefs =
@@ -660,6 +661,9 @@ fn category_fields(ui: &mut egui::Ui, app: &mut VectorcraftApp, d: &mut Dialog,
ui.label(egui::RichText::new(note).color(t.text_dim).size(11.0));
}
}
// The desktop app only: it sets the window's present mode when it starts, so a note
// says the change applies at the next start.
PrefKind::Bool if sp.key == "lowLatencyDrawing" => desktop_startup_bool_row(ui, d, sp.key, sp.label, &t),
PrefKind::Bool => bool_row(ui, d, sp.key, sp.label),
PrefKind::Num { min, max, unit } => {
labeled(ui, sp.label, |ui, label_id| {
@@ -883,6 +887,16 @@ fn bool_row(ui: &mut egui::Ui, d: &mut Dialog, key: &str, label: &str) {
}
}
/// A checkbox the desktop app reads once, when it starts (Performance › Low-Latency Drawing, which
/// sets the window's present mode), with its restart note. The web build doesn't show it.
fn desktop_startup_bool_row(ui: &mut egui::Ui, d: &mut Dialog, key: &str, label: &str, t: &Tokens) {
if cfg!(target_arch = "wasm32") {
return;
}
bool_row(ui, d, key, label);
ui.label(egui::RichText::new(tl!("Applies the next time VectorCraft starts.")).color(t.text_dim).size(11.0));
}
fn labeled(ui: &mut egui::Ui, label: &str, add: impl FnOnce(&mut egui::Ui, egui::Id)) {
let t = Tokens::get(ui.ctx());
ui.horizontal(|ui| {
+38
View File
@@ -512,6 +512,44 @@ fn graphics_processor_preference_shows_and_persists() {
assert_eq!(saved["engine_prefs"]["gpuPreference"], json!("highPerformance"));
}
/// Performance › Low-Latency Drawing (#6013): shown off with its restart note, applied by OK,
/// saved with the UI state under the key the desktop app reads before the window opens, and every
/// bundled language translates its label.
#[test]
fn low_latency_drawing_preference_shows_and_persists() {
fn texts(s: &egui::Shape, out: &mut Vec<String>) {
match s {
egui::Shape::Text(t) => out.push(t.galley.text().to_string()),
egui::Shape::Vec(v) => v.iter().for_each(|s| texts(s, out)),
_ => {}
}
}
let mut a = app();
open(&mut a, Some("Performance"));
assert_eq!(a.ui.dialog.as_ref().unwrap().fields.get("lowLatencyDrawing"), Some(&json!(false)));
let ctx = egui::Context::default();
crate::theme::install_fonts(&ctx);
let mut out = ctx.run_ui(egui::RawInput::default(), |ui| show(&mut a, ui.ctx()));
out.textures_delta.clear();
let mut out = ctx.run_ui(egui::RawInput::default(), |ui| show(&mut a, ui.ctx()));
out.textures_delta.clear();
let mut shown = vec![];
out.shapes.iter().for_each(|c| texts(&c.shape, &mut shown));
let at = shown.iter().position(|t| t == "Low-Latency Drawing").unwrap_or_else(|| panic!("{shown:?}"));
// The note is the row's own: it comes before the next row's label.
let next = shown[at..].iter().position(|t| t.starts_with("History States")).map(|n| at + n).unwrap_or_else(|| panic!("{shown:?}"));
assert!(shown[at..next].iter().any(|t| t == "Applies the next time VectorCraft starts."), "{shown:?}");
a.ui.dialog.as_mut().unwrap().fields.insert("lowLatencyDrawing".into(), json!(true));
confirm(&mut a).unwrap();
assert!(a.take_prefs_changed(), "OK asks the host to write the preferences file");
assert!(a.session.prefs.low_latency_drawing);
let saved: Value = serde_json::from_slice(&serde_json::to_vec(&a.ui).unwrap()).unwrap();
assert_eq!(saved["engine_prefs"]["lowLatencyDrawing"], json!(true));
for lang in crate::i18n::Lang::all().filter(|l| l.code() != crate::i18n::Lang::EN.code()) {
assert!(crate::i18n::has(lang, "Low-Latency Drawing"), "{}", lang.code());
}
}
/// User Interface › System Title Bar: shown with its next-launch note, applied by OK and
/// saved with the UI state under the key the desktop app reads before the window opens.
#[test]
+1
View File
@@ -84,6 +84,7 @@ The canvas is rasterized on the CPU (`vectorcraft-render`, vello_cpu); the GPU (
- On Linux with Mesa, `MESA_VK_DEVICE_SELECT=10de:2f04!` (vendor:device as `vulkaninfo --summary` or `lspci -nn` show it) leaves only that GPU to Vulkan, and `DRI_PRIME=1` picks the other GPU.
- Help › About and the control channel's `ui.inspect` (`graphicsAdapter`) show the adapter in use, and the app logs it at startup.
- **How frames reach the display.** By default the window presents with `autovsync` and lets the display queue one frame. With `autovsync`, wgpu uses relaxed vsync (FifoRelaxed, which tears a frame that arrives late) where the driver offers it, else vsync (Fifo). For a launch, `--present-mode` (or `VECTORCRAFT_PRESENT_MODE`) sets the present mode to `fifo` (vsync), `autovsync` or `novsync` (wgpu uses Immediate, else Mailbox, else Fifo, whichever the driver offers), and `--frame-latency` (or `VECTORCRAFT_FRAME_LATENCY`) sets the frames the display may queue, `1` to `3`. A flag overrides its variable, and a value that is not one of these stops the app with a message. On Windows and Linux, a launch with either one set opens its files in a new window, as with `--new-instance`, instead of handing them to a running VectorCraft. At startup the log records what the app asks the window surface for, for example `requested window surface: autovsync, frame latency 2 (override)`. The driver chooses the mode that `autovsync` and `novsync` resolve to and may clamp the latency, and on macOS egui uses at least 2 frames while the window is being resized. The code is `apps/vectorcraft/src/presentation.rs`.
- **Preferences › Performance › Low-Latency Drawing** (`lowLatencyDrawing`, off by default) presents with `novsync` and is read when the app starts, so a change applies after a restart. The present mode comes from `--present-mode` first, then `VECTORCRAFT_PRESENT_MODE`, then this preference, then the default (`autovsync`); `--frame-latency` and `VECTORCRAFT_FRAME_LATENCY` still set the latency with it on. The log names where the mode came from: `requested window surface: novsync (preference), frame latency 1`. Whenever the window presents without vsync (`novsync`, from the preference or an override), frames start at most 240 times a second (about 4.17 ms apart); with vsync the display paces them and no cap applies.
## Logs
+5
View File
@@ -7065,6 +7065,11 @@ is converted on its own.
osManaged}`, where `source` is `profile`, `srgbProfile` (a profile that shows sRGB unchanged), `system`, `none`,
`pending` or `unsupported`, `applied` says whether the canvas is converted, and `reason` says why not.
`lowLatencyDrawing` (Preferences › Performance › Low-Latency Drawing, off by default; desktop app) is read when the app
starts. On, the window presents without vsync (wgpu's `AutoNoVsync`) and frames start at most 240 times a second.
`--present-mode` and `VECTORCRAFT_PRESENT_MODE` take precedence over it (see `docs/development.md` › Desktop graphics
processor). A value that is not a boolean is an error.
`ctrlWheelScrollsSideways` (on by default): on, Cmd/Ctrl with a mouse wheel's whole notches scrolls the canvas sideways
instead of zooming while `zoomWithMouseWheel` is off; off, Cmd/Ctrl-wheel zooms about the pointer. Alt + Cmd/Ctrl-wheel
and a pinch on a Mac trackpad, on a touch screen or in the web build still zoom about the pointer. Under either