xref: /aosp_15_r20/external/mesa3d/src/gallium/frontends/rusticl/mesa/pipe/fence.rs (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 use crate::pipe::screen::*;
2 
3 use libc_rust_gen::close;
4 use mesa_rust_gen::*;
5 
6 use std::sync::Arc;
7 
8 pub struct FenceFd {
9     pub fd: i32,
10 }
11 
12 impl Drop for FenceFd {
drop(&mut self)13     fn drop(&mut self) {
14         unsafe {
15             close(self.fd);
16         }
17     }
18 }
19 
20 pub struct PipeFence {
21     fence: *mut pipe_fence_handle,
22     screen: Arc<PipeScreen>,
23 }
24 
25 impl PipeFence {
new(fence: *mut pipe_fence_handle, screen: &Arc<PipeScreen>) -> Self26     pub fn new(fence: *mut pipe_fence_handle, screen: &Arc<PipeScreen>) -> Self {
27         Self {
28             fence: fence,
29             screen: screen.clone(),
30         }
31     }
32 
wait(&self)33     pub fn wait(&self) {
34         self.screen.fence_finish(self.fence);
35     }
36 }
37 
38 impl Drop for PipeFence {
drop(&mut self)39     fn drop(&mut self) {
40         self.screen.unref_fence(self.fence);
41     }
42 }
43