session: plafonne les trames pre-rendues par le pilote NVIDIA

Passe __GL_MaxFramesAllowed=1 a cosmic-comp lorsque /proc/driver/nvidia
existe. Sans cela le pilote laisse grossir sa file de trames pre-rendues,
ce qui ajoute de la latence a l'affichage (smithay#1562, cosmic-comp#1179).

La variable n'est ajoutee que sur machine NVIDIA ; ailleurs l'environnement
transmis reste le seul COSMIC_SESSION_SOCK.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Lionel DARNIS 2026-08-21 09:54:33 +02:00
parent bc61bfddcc
commit fa2d2a40ce
2 changed files with 18 additions and 9 deletions

16
Cargo.lock generated
View file

@ -1889,14 +1889,6 @@ dependencies = [
name = "softbuffer"
version = "0.4.1"
[[patch.unused]]
name = "cosmic-freedesktop-icons"
version = "0.4.0"
[[patch.unused]]
name = "smithay-clipboard"
version = "0.8.0"
[[patch.unused]]
name = "dpi"
version = "0.1.2"
@ -1944,3 +1936,11 @@ version = "0.31.0-beta.2"
[[patch.unused]]
name = "winit-x11"
version = "0.31.0-beta.2"
[[patch.unused]]
name = "cosmic-freedesktop-icons"
version = "0.4.0"
[[patch.unused]]
name = "smithay-clipboard"
version = "0.8.0"

View file

@ -122,12 +122,21 @@ pub fn run_compositor(
Ok(tokio::spawn(async move {
// Create a new process handler for cosmic-comp, with our compositor socket's
// file descriptor as the `COSMIC_SESSION_SOCK` environment variable.
let mut comp_env = vec![(
"COSMIC_SESSION_SOCK".to_string(),
comp.as_raw_fd().to_string(),
)];
// NVIDIA keeps a growing pool of pre-rendered compositor frames
// (smithay#1562 / cosmic-comp#1179). Cap it to a single buffer.
if std::path::Path::new("/proc/driver/nvidia").exists() {
comp_env.push(("__GL_MaxFramesAllowed".to_string(), "1".to_string()));
}
process_manager
.start_process(
Process::new()
.with_executable(exec)
.with_args(args)
.with_env([("COSMIC_SESSION_SOCK", comp.as_raw_fd().to_string())])
.with_env(comp_env)
.with_on_exit(move |pman, _, err_code, _will_restart| {
let session_dbus_tx = session_dbus_tx.clone();
async move {