Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
perf(compositor): reuse the kept background's texture on Windows and macOS
Etienne Lescot0624c1481d44
diff --git a/crates/compositor/src/compositor_macos.rs b/crates/compositor/src/compositor_macos.rsindex 22cfc9fdb..5440cfb51 100644--- a/crates/compositor/src/compositor_macos.rs+++ b/crates/compositor/src/compositor_macos.rs@@ -2409,14 +2409,18 @@ impl Compositor {.then(|| crate::frame_geometry::BackgroundKey::of(bg_desc, bg_blur, lp.bg_color, [rw, rh])).flatten();if let Some(key) = key {- let tex = make_texture(- &self.gpu.device,- metal::MTLPixelFormat::RGBA8Unorm,- self.render_w,- self.render_h,- metal::MTLStorageMode::Private,- metal::MTLTextureUsage::ShaderRead,- );+ // L'ancienne texture est reprise : `resized` vide le cache, sa taille est la bonne.+ let old = self.bg_cache.borrow_mut().take().map(|c| c.tex);+ let tex = old.unwrap_or_else(|| {+ make_texture(+ &self.gpu.device,+ metal::MTLPixelFormat::RGBA8Unorm,+ self.render_w,+ self.render_h,+ metal::MTLStorageMode::Private,+ metal::MTLTextureUsage::ShaderRead,+ )+ });self.blit_background(cmd_buf, &tex, false);*self.bg_cache.borrow_mut() = Some(BgCache { key, tex });}diff --git a/crates/compositor/src/compositor_windows.rs b/crates/compositor/src/compositor_windows.rsindex f9be386bd..11952713d 100644--- a/crates/compositor/src/compositor_windows.rs+++ b/crates/compositor/src/compositor_windows.rs@@ -973,12 +973,19 @@ impl Compositor {/// Garde le fond que le RT porte à cet instant (`bg_cache`), sous `key`.unsafe fn keep_background(&self, key: crate::frame_geometry::BackgroundKey) -> Result<()> {- let mut d = D3D11_TEXTURE2D_DESC::default();- self.rt.GetDesc(&mut d);- d.BindFlags = 0;- let mut tex: Option<ID3D11Texture2D> = None;- self.dev.CreateTexture2D(&d, None, Some(&mut tex))?;- let tex = tex.ok_or_else(|| anyhow::anyhow!("CreateTexture2D (fond gardé)"))?;+ // L'ancienne texture est reprise : `resized` vide le cache, sa taille est la bonne.+ let old = self.bg_cache.borrow_mut().take().map(|c| c.tex);+ let tex = match old {+ Some(tex) => tex,+ None => {+ let mut d = D3D11_TEXTURE2D_DESC::default();+ self.rt.GetDesc(&mut d);+ d.BindFlags = 0;+ let mut tex: Option<ID3D11Texture2D> = None;+ self.dev.CreateTexture2D(&d, None, Some(&mut tex))?;+ tex.ok_or_else(|| anyhow::anyhow!("CreateTexture2D (fond gardé)"))?+ }+ };self.ctx.CopyResource(&tex, &self.rt);*self.bg_cache.borrow_mut() = Some(BgCache { key, tex });Ok(())