From f86cd933d483b450afbffc7574d727a39ffe878b Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Wed, 28 May 2025 11:27:50 -0700 Subject: [PATCH] kms/surface: Call `cleanup_texture_cache` for each device at end of draw Fixes an issue where a dual GPU system would keep allocating dGPU PBOs in `cpu_copy()` every frame, but `cleanup()` was not being called, since the surface thread for the builtin output was rendered on the primary/integrated GPU, targeting the same GPU. Even if a different monitor was compositing on the dGPU, That wouldn't help since that thread has it's own `GpuManager` with it's own renderer and cache. Running cleanup at the end (or start) of each frame seems like a good idea. Not sure if it would be best to avoid additional calls, or if that's desirable/fine. --- src/backend/kms/surface/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/backend/kms/surface/mod.rs b/src/backend/kms/surface/mod.rs index a90853ff..78b94f00 100644 --- a/src/backend/kms/surface/mod.rs +++ b/src/backend/kms/surface/mod.rs @@ -45,7 +45,7 @@ use smithay::{ element::TextureShaderElement, GlesRenderbuffer, GlesRenderer, GlesTexture, Uniform, }, glow::GlowRenderer, - multigpu::{Error as MultiError, GpuManager}, + multigpu::{ApiDevice, Error as MultiError, GpuManager}, sync::SyncPoint, utils::with_renderer_surface_state, Bind, Blit, Frame, ImportDma, Offscreen, Renderer, RendererSuper, Texture, @@ -1751,6 +1751,10 @@ impl SurfaceThreadState { } } + for device in self.api.devices_mut()? { + device.renderer_mut().cleanup_texture_cache()?; + } + Ok(()) }