fix(gpui): resolve GPU atlas VRAM leak and GStreamer pipeline latency

- Fix unbounded Blade texture atlas allocation in GPUI by recycling textures via window.drop_image() with a 2-frame safety buffer.
- Correct RGBA to BGRA color channel order for GPUI polychrome texture atlas.
- Optimize GStreamer UDP pipeline: increase socket buffer to 4MB, add rtpjitterbuffer for zero-latency drops, scale before colorspace conversion.
- Add log filter controls (All, Warn/Err, Err) to GPUI console drawer.
- Benchmark: memory consumption stays completely flat at ~258 MB over time.
This commit is contained in:
bleackstorm committed 2026-11-05 21:23:49 +01:00
1 parent be48fbdedf
commit 0fbe184716
4 files changed
+105 -18

No files matched your search

+99 -16
View File
@@ -22,7 +22,6 @@ const COLOR_BG_DARK: u32 = 0x090b10;
const COLOR_SURFACE_CARD: u32 = 0x11151f;
const COLOR_SURFACE_ELEVATED: u32 = 0x181e2b;
const COLOR_BORDER_SUBTLE: u32 = 0x1f293d;
const COLOR_BORDER_ACCENT: u32 = 0x00e5ff;
const COLOR_CYAN: u32 = 0x00e5ff;
const COLOR_GREEN: u32 = 0x10b981;
@@ -37,6 +36,7 @@ pub struct SteamFrameGpuiApp {
log_buffer: Arc<Mutex<LogBuffer>>,
log_filter: LogFilter,
current_render_image: Option<Arc<RenderImage>>,
images_to_drop: Vec<Arc<RenderImage>>,
last_frame_seq: u64,
// Snapshots pour l'affichage réactif
usb_status: SubsystemStatus,
@@ -64,6 +64,7 @@ impl SteamFrameGpuiApp {
log_buffer,
log_filter: LogFilter::All,
current_render_image: None,
images_to_drop: Vec::new(),
last_frame_seq: 0,
usb_status: SubsystemStatus::Starting,
xr_status: SubsystemStatus::Starting,
@@ -80,7 +81,7 @@ impl SteamFrameGpuiApp {
}
/// Synchronise l'état IHM avec le moteur FPV en tâche de fond
fn sync_from_engine(&mut self) {
fn sync_from_engine(&mut self, window: &mut Window) {
let mon = self.engine.monitor.lock();
// 1. Mise à jour de la texture vidéo si une nouvelle trame est arrivée
@@ -89,14 +90,36 @@ impl SteamFrameGpuiApp {
&& mon.preview_width > 0
&& mon.preview_height > 0
{
if let Some(img_buf) = RgbaImage::from_raw(
if let Some(mut img_buf) = RgbaImage::from_raw(
mon.preview_width,
mon.preview_height,
mon.preview_rgba.clone(),
) {
// Conversion RGBA -> BGRA requise par l'atlas polychrome GPUI / Vulkan
for pixel in img_buf.chunks_exact_mut(4) {
pixel.swap(0, 2);
}
let frame = Frame::new(img_buf);
self.current_render_image = Some(Arc::new(RenderImage::new(smallvec![frame])));
let new_render_image = Arc::new(RenderImage::new(smallvec![frame]));
if let Some(old) = self.current_render_image.take() {
self.images_to_drop.push(old);
}
self.current_render_image = Some(new_render_image);
self.last_frame_seq = mon.preview_frame_seq;
// Nettoyage de l'atlas texture GPU pour empêcher l'accumulation de VRAM.
// On conserve les 2 dernières trames pour garantir que le GPU a fini
// de les projeter à l'écran avant destruction de la texture.
while self.images_to_drop.len() > 2 {
let old_img = self.images_to_drop.remove(0);
let _ = window.drop_image(old_img);
}
}
} else if !self.images_to_drop.is_empty() {
// Si le flux s'interrompt, purger les anciennes textures en attente
for old_img in self.images_to_drop.drain(..) {
let _ = window.drop_image(old_img);
}
}
@@ -787,6 +810,63 @@ impl SteamFrameGpuiApp {
div()
.flex()
.gap_2()
.child(
div()
.id("filter_all")
.px_2()
.py_0p5()
.bg(if self.log_filter == LogFilter::All {
rgb(0x1e3a5f)
} else {
rgb(COLOR_SURFACE_ELEVATED)
})
.rounded_md()
.text_xs()
.cursor_pointer()
.on_click(cx.listener(|this, _, _, cx| {
this.log_filter = LogFilter::All;
cx.notify();
}))
.child("Tous"),
)
.child(
div()
.id("filter_warn")
.px_2()
.py_0p5()
.bg(if self.log_filter == LogFilter::WarningsAndErrors {
rgb(0x1e3a5f)
} else {
rgb(COLOR_SURFACE_ELEVATED)
})
.rounded_md()
.text_xs()
.cursor_pointer()
.on_click(cx.listener(|this, _, _, cx| {
this.log_filter = LogFilter::WarningsAndErrors;
cx.notify();
}))
.child("Warn/Err"),
)
.child(
div()
.id("filter_err")
.px_2()
.py_0p5()
.bg(if self.log_filter == LogFilter::ErrorsOnly {
rgb(0x1e3a5f)
} else {
rgb(COLOR_SURFACE_ELEVATED)
})
.rounded_md()
.text_xs()
.cursor_pointer()
.on_click(cx.listener(|this, _, _, cx| {
this.log_filter = LogFilter::ErrorsOnly;
cx.notify();
}))
.child("Err"),
)
.child(
div()
.id("btn_clear_logs")
@@ -807,15 +887,6 @@ impl SteamFrameGpuiApp {
cx.notify();
}))
.child("Effacer"),
)
.child(
div()
.px_2()
.py_0p5()
.bg(rgb(COLOR_SURFACE_ELEVATED))
.rounded_md()
.text_xs()
.child("Copier"),
),
),
)
@@ -828,7 +899,19 @@ impl SteamFrameGpuiApp {
.overflow_scroll()
.px_2()
.gap_0p5()
.children(self.log_entries.iter().rev().take(40).map(|e| {
.children(
self.log_entries
.iter()
.rev()
.filter(|e| match self.log_filter {
LogFilter::All => true,
LogFilter::WarningsAndErrors => {
matches!(e.level, log::Level::Warn | log::Level::Error)
}
LogFilter::ErrorsOnly => matches!(e.level, log::Level::Error),
})
.take(40)
.map(|e| {
let badge_color = match e.level {
log::Level::Error => COLOR_RED,
log::Level::Warn => COLOR_ORANGE,
@@ -972,10 +1055,10 @@ pub fn run_gpui_app(cfg: AppConfig, log_buffer: Arc<Mutex<LogBuffer>>) -> Result
loop {
Timer::after(Duration::from_millis(16)).await;
let should_continue = cx
.update(|_, cx| {
.update(|window, cx| {
if let Some(view) = weak_view.upgrade() {
view.update(cx, |this, cx| {
this.sync_from_engine();
this.sync_from_engine(window);
cx.notify();
});
true