1
0
Fork 0
forked from wry/wry

Merge pull request #734 from mahkoh/jorth/unique-buffer-ids

gfx: identify wl_buffer by address during ctx change
This commit is contained in:
mahkoh 2026-02-10 20:46:22 +01:00 committed by GitHub
commit 7122b89cb9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 10 additions and 11 deletions

View file

@ -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<ClMatcherChange>,
pub destroyed: CopyHashMap<CritMatcherId, Weak<dyn CritDestroyListener<Rc<Self>>>>,
pub acceptor: Rc<AcceptorMetadata>,
pub gfx_ctx_changed: EventSource<WlBuffer>,
}
pub const NUM_CACHED_SERIAL_RANGES: usize = 64;

View file

@ -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);

View file

@ -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
}

View file

@ -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<WorkspaceDisplayOrder>,
pub outputs_without_hc: NumCell<usize>,
pub udmabuf: Rc<UdmabufHolder>,
pub gfx_ctx_changed: EventSource<WlBuffer>,
}
// 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);
}