From 86a765718dae70e150197c04f24cbf9f913972bd Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Tue, 10 Feb 2026 20:24:56 +0100 Subject: [PATCH] gfx: identify wl_buffer by address during ctx change --- src/client.rs | 4 ---- src/compositor.rs | 1 + src/ifs/wl_buffer.rs | 2 +- src/state.rs | 14 ++++++++------ 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/client.rs b/src/client.rs index b676ea38..75f1ea6e 100644 --- a/src/client.rs +++ b/src/client.rs @@ -7,7 +7,6 @@ use { clm::{CL_CHANGED_DESTROYED, CL_CHANGED_NEW, ClMatcherChange}, }, ifs::{ - wl_buffer::WlBuffer, wl_display::WlDisplay, wl_registry::WlRegistry, wl_surface::{WlSurface, commit_timeline::CommitTimelines}, @@ -22,7 +21,6 @@ use { buffd::{MsgFormatter, MsgParser, MsgParserError, OutBufferSwapchain}, copyhashmap::{CopyHashMap, Locked}, errorfmt::ErrorFmt, - event_listener::EventSource, numcell::NumCell, pending_serial::PendingSerial, pid_info::{PidInfo, get_pid_info, get_socket_creds}, @@ -196,7 +194,6 @@ impl Clients { changed_properties: Default::default(), destroyed: Default::default(), acceptor: acceptor.clone(), - gfx_ctx_changed: Default::default(), }); track!(data, data); global.update_capabilities(&data, bounding_caps, set_bounding_caps_for_children); @@ -324,7 +321,6 @@ pub struct Client { pub changed_properties: Cell, pub destroyed: CopyHashMap>>>, pub acceptor: Rc, - pub gfx_ctx_changed: EventSource, } pub const NUM_CACHED_SERIAL_RANGES: usize = 64; diff --git a/src/compositor.rs b/src/compositor.rs index 0e333e56..94b63659 100644 --- a/src/compositor.rs +++ b/src/compositor.rs @@ -361,6 +361,7 @@ fn start_compositor2( workspace_display_order: Cell::new(WorkspaceDisplayOrder::Manual), outputs_without_hc: Default::default(), udmabuf: Default::default(), + gfx_ctx_changed: Default::default(), }); state.tracker.register(ClientId::from_raw(0)); create_dummy_output(&state); diff --git a/src/ifs/wl_buffer.rs b/src/ifs/wl_buffer.rs index e7df2349..47a9612f 100644 --- a/src/ifs/wl_buffer.rs +++ b/src/ifs/wl_buffer.rs @@ -101,7 +101,7 @@ impl WlBuffer { color, gfx_ctx_changed: EventListener::new(slf.clone()), }); - slf.gfx_ctx_changed.attach(&client.gfx_ctx_changed); + slf.gfx_ctx_changed.attach(&client.state.gfx_ctx_changed); slf } diff --git a/src/state.rs b/src/state.rs index 80fe12d3..3708e935 100644 --- a/src/state.rs +++ b/src/state.rs @@ -52,6 +52,7 @@ use { jay_screencast::JayScreencast, jay_seat_events::JaySeatEvents, jay_workspace_watcher::JayWorkspaceWatcher, + wl_buffer::WlBuffer, wl_drm::WlDrmGlobal, wl_output::{OutputGlobalOpt, OutputId, PersistentOutputState}, wl_seat::{ @@ -290,6 +291,7 @@ pub struct State { pub workspace_display_order: Cell, pub outputs_without_hc: NumCell, pub udmabuf: Rc, + pub gfx_ctx_changed: EventSource, } // impl Drop for State { @@ -677,16 +679,16 @@ impl State { } Walker.visit_display(&self.root); let mut updated_buffers = AHashMap::new(); + for buffer in self.gfx_ctx_changed.iter() { + let had_buffer_texture = buffer.handle_gfx_context_change(); + updated_buffers.insert(Rc::as_ptr(&buffer), had_buffer_texture); + } for client in self.clients.clients.borrow_mut().values() { - updated_buffers.clear(); - for buffer in client.data.gfx_ctx_changed.iter() { - let had_buffer_texture = buffer.handle_gfx_context_change(); - updated_buffers.insert(buffer.id, had_buffer_texture); - } for surface in client.data.objects.surfaces.lock().values() { let had_shm_texture = surface.reset_shm_textures(); if let Some(buffer) = surface.buffer.get() { - let had_buffer_texture = *updated_buffers.get(&buffer.buffer.id).unwrap(); + let had_buffer_texture = + *updated_buffers.get(&Rc::as_ptr(&buffer.buffer)).unwrap(); if had_shm_texture || had_buffer_texture { buffer.buffer.update_texture_or_log(surface, true); }