@@ -124,14 +124,14 @@ use std::{
124
124
collections:: { HashMap , HashSet } ,
125
125
fmt:: Debug ,
126
126
io:: ErrorKind ,
127
- os:: unix:: io:: { AsFd , OwnedFd } ,
127
+ os:: unix:: io:: { AsFd , BorrowedFd , OwnedFd } ,
128
128
rc:: Rc ,
129
129
sync:: { Arc , Mutex } ,
130
130
} ;
131
131
132
132
use :: gbm:: { BufferObject , BufferObjectFlags } ;
133
133
use drm:: {
134
- control:: { connector, crtc, framebuffer, plane, Mode , PlaneType } ,
134
+ control:: { connector, crtc, Device as _ , framebuffer, plane, Mode , PlaneType } ,
135
135
Device , DriverCapability ,
136
136
} ;
137
137
use drm_fourcc:: { DrmFormat , DrmFourcc , DrmModifier } ;
@@ -634,7 +634,7 @@ impl<B: Framebuffer> FrameState<B> {
634
634
let backup = current_config. clone ( ) ;
635
635
* current_config = state;
636
636
637
- let res = surface. test_state ( self . build_planes ( surface, supports_fencing, true ) , allow_modeset) ;
637
+ let res = surface. test_state ( self . build_planes ( surface, supports_fencing, true , None ) , allow_modeset) ;
638
638
639
639
if res. is_err ( ) {
640
640
// test failed, restore previous state
@@ -674,7 +674,7 @@ impl<B: Framebuffer> FrameState<B> {
674
674
}
675
675
676
676
let res = surface. test_state (
677
- self . build_planes ( surface, supports_fencing, allow_partial_update) ,
677
+ self . build_planes ( surface, supports_fencing, allow_partial_update, None ) ,
678
678
allow_modeset,
679
679
) ;
680
680
@@ -694,11 +694,14 @@ impl<B: Framebuffer> FrameState<B> {
694
694
supports_fencing : bool ,
695
695
allow_partial_update : bool ,
696
696
event : bool ,
697
+ out_fence_fd : & mut Option < OwnedFd > ,
698
+ signalled_sync_file : Option < BorrowedFd < ' _ > > , // XXX
697
699
) -> Result < ( ) , crate :: backend:: drm:: error:: Error > {
698
700
debug_assert ! ( !self . planes. iter( ) . any( |( _, state) | state. needs_test) ) ;
699
701
surface. commit (
700
- self . build_planes ( surface, supports_fencing, allow_partial_update) ,
702
+ self . build_planes ( surface, supports_fencing, allow_partial_update, signalled_sync_file ) ,
701
703
event,
704
+ Some ( out_fence_fd) ,
702
705
)
703
706
}
704
707
@@ -709,11 +712,14 @@ impl<B: Framebuffer> FrameState<B> {
709
712
supports_fencing : bool ,
710
713
allow_partial_update : bool ,
711
714
event : bool ,
715
+ out_fence_fd : & mut Option < OwnedFd > ,
716
+ signalled_sync_file : Option < BorrowedFd < ' _ > > , // XXX
712
717
) -> Result < ( ) , crate :: backend:: drm:: error:: Error > {
713
718
debug_assert ! ( !self . planes. iter( ) . any( |( _, state) | state. needs_test) ) ;
714
719
surface. page_flip (
715
- self . build_planes ( surface, supports_fencing, allow_partial_update) ,
720
+ self . build_planes ( surface, supports_fencing, allow_partial_update, signalled_sync_file ) ,
716
721
event,
722
+ Some ( out_fence_fd)
717
723
)
718
724
}
719
725
@@ -723,6 +729,7 @@ impl<B: Framebuffer> FrameState<B> {
723
729
surface : & ' a DrmSurface ,
724
730
supports_fencing : bool ,
725
731
allow_partial_update : bool ,
732
+ signalled_sync_file : Option < BorrowedFd < ' a > > , // XXX
726
733
) -> impl IntoIterator < Item = super :: PlaneState < ' a > > {
727
734
for ( _, state) in self . planes . iter_mut ( ) . filter ( |( _, state) | !state. skip ) {
728
735
if let Some ( config) = state. config . as_mut ( ) {
@@ -759,10 +766,14 @@ impl<B: Framebuffer> FrameState<B> {
759
766
transform : config. properties . transform ,
760
767
damage_clips : config. damage_clips . as_ref ( ) . map ( |d| d. blob ( ) ) ,
761
768
fb : * config. buffer . as_ref ( ) ,
769
+ // XXX
770
+ fence : signalled_sync_file
771
+ /*
762
772
fence: config
763
773
.sync
764
774
.as_ref()
765
775
.and_then(|(_, fence)| fence.as_ref().map(|fence| fence.as_fd())),
776
+ */
766
777
} ) ,
767
778
} )
768
779
}
@@ -1514,6 +1525,8 @@ where
1514
1525
1515
1526
debug_flags : DebugFlags ,
1516
1527
span : tracing:: Span ,
1528
+
1529
+ signalled_sync_file : Option < OwnedFd > ,
1517
1530
}
1518
1531
1519
1532
impl < A , F , U , G > DrmCompositor < A , F , U , G >
@@ -1600,6 +1613,14 @@ where
1600
1613
} ) ?
1601
1614
&& plane_has_property ( & * surface, surface. plane ( ) , "IN_FENCE_FD" ) ?;
1602
1615
1616
+ let mut signalled_sync_file = None ;
1617
+ if supports_fencing {
1618
+ // XXX unwrap
1619
+ let syncobj = surface. device_fd ( ) . create_syncobj ( true ) . unwrap ( ) ;
1620
+ signalled_sync_file = Some ( surface. device_fd ( ) . syncobj_to_fd ( syncobj, true ) . unwrap ( ) ) ;
1621
+ surface. device_fd ( ) . destroy_syncobj ( syncobj) . unwrap ( ) ;
1622
+ }
1623
+
1603
1624
for format in color_formats {
1604
1625
debug ! ( "Testing color format: {}" , format) ;
1605
1626
match Self :: find_supported_format (
@@ -1663,6 +1684,7 @@ where
1663
1684
supports_fencing,
1664
1685
debug_flags : DebugFlags :: empty ( ) ,
1665
1686
span,
1687
+ signalled_sync_file,
1666
1688
} ;
1667
1689
1668
1690
return Ok ( drm_renderer) ;
@@ -2558,16 +2580,20 @@ where
2558
2580
} = self . queued_frame . take ( ) . unwrap ( ) ;
2559
2581
2560
2582
let allow_partial_update = prepared_frame. kind == PreparedFrameKind :: Partial ;
2583
+ let mut out_fence_fd = None ;
2584
+ let signalled_sync_file = self . signalled_sync_file . as_ref ( ) . map ( |x| x. as_fd ( ) ) ;
2561
2585
let flip = if self . surface . commit_pending ( ) {
2562
2586
prepared_frame
2563
2587
. frame
2564
- . commit ( & self . surface , self . supports_fencing , allow_partial_update, true )
2588
+ . commit ( & self . surface , self . supports_fencing , allow_partial_update, true , & mut out_fence_fd , signalled_sync_file )
2565
2589
} else {
2566
2590
prepared_frame
2567
2591
. frame
2568
- . page_flip ( & self . surface , self . supports_fencing , allow_partial_update, true )
2592
+ . page_flip ( & self . surface , self . supports_fencing , allow_partial_update, true , & mut out_fence_fd , signalled_sync_file )
2569
2593
} ;
2570
2594
2595
+ dbg ! ( out_fence_fd) ;
2596
+
2571
2597
match flip {
2572
2598
Ok ( _) => {
2573
2599
if prepared_frame. kind == PreparedFrameKind :: Full {
0 commit comments