Skip to content

Commit 2029153

Browse files
committed
Add sync points to double buffered surface state
1 parent 61ba0d2 commit 2029153

File tree

1 file changed

+47
-5
lines changed

1 file changed

+47
-5
lines changed

src/wayland/drm_syncobj/mod.rs

+47-5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,36 @@ use wayland_server::{
88
protocol::wl_surface::WlSurface, Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource,
99
};
1010

11+
use super::compositor::{with_states, Cacheable};
12+
13+
#[derive(Clone)]
14+
struct SyncPoint {
15+
fd: Arc<OwnedFd>,
16+
point: u64,
17+
}
18+
19+
#[derive(Default)]
20+
struct DrmSyncobjCachedState {
21+
acquire_point: Option<SyncPoint>,
22+
release_point: Option<SyncPoint>,
23+
}
24+
25+
impl Cacheable for DrmSyncobjCachedState {
26+
fn commit(&mut self, _dh: &DisplayHandle) -> Self {
27+
Self {
28+
acquire_point: None,
29+
release_point: None,
30+
}
31+
}
32+
33+
fn merge_into(self, into: &mut Self, _dh: &DisplayHandle) {
34+
// TODO need to verify that buffer, acquire point, and release point are sent together
35+
// in one commit, or send `no_buffer`, `no_acquire_point`, `no_release_point`
36+
into.acquire_point = self.acquire_point;
37+
into.release_point = self.release_point;
38+
}
39+
}
40+
1141
pub struct DrmSyncobjState {}
1242

1343
impl DrmSyncobjState {
@@ -67,7 +97,7 @@ impl<D> Dispatch<WpLinuxDrmSyncobjSurfaceV1, DrmSyncobjSurfaceData, D> for DrmSy
6797
_client: &Client,
6898
_resource: &WpLinuxDrmSyncobjSurfaceV1,
6999
request: wp_linux_drm_syncobj_surface_v1::Request,
70-
_data: &DrmSyncobjSurfaceData,
100+
data: &DrmSyncobjSurfaceData,
71101
_dh: &DisplayHandle,
72102
data_init: &mut DataInit<'_, D>,
73103
) {
@@ -78,16 +108,28 @@ impl<D> Dispatch<WpLinuxDrmSyncobjSurfaceV1, DrmSyncobjSurfaceData, D> for DrmSy
78108
point_hi,
79109
point_lo,
80110
} => {
81-
let fd = &timeline.data::<DrmSyncobjTimelineData>().unwrap().fd;
82-
let point = ((point_hi as u64) << 32) + (point_lo as u64);
111+
let sync_point = SyncPoint {
112+
fd: timeline.data::<DrmSyncobjTimelineData>().unwrap().fd.clone(),
113+
point: ((point_hi as u64) << 32) + (point_lo as u64),
114+
};
115+
with_states(&data.surface, |states| {
116+
let mut cached_state = states.cached_state.pending::<DrmSyncobjCachedState>();
117+
cached_state.acquire_point = Some(sync_point);
118+
});
83119
}
84120
wp_linux_drm_syncobj_surface_v1::Request::SetReleasePoint {
85121
timeline,
86122
point_hi,
87123
point_lo,
88124
} => {
89-
let fd = &timeline.data::<DrmSyncobjTimelineData>().unwrap().fd;
90-
let point = ((point_hi as u64) << 32) + (point_lo as u64);
125+
let sync_point = SyncPoint {
126+
fd: timeline.data::<DrmSyncobjTimelineData>().unwrap().fd.clone(),
127+
point: ((point_hi as u64) << 32) + (point_lo as u64),
128+
};
129+
with_states(&data.surface, |states| {
130+
let mut cached_state = states.cached_state.pending::<DrmSyncobjCachedState>();
131+
cached_state.release_point = Some(sync_point);
132+
});
91133
}
92134
_ => unreachable!(),
93135
}

0 commit comments

Comments
 (0)