rusticl/mesa: add PipeResource::new_ref
pipe_resources are already ref counted, so we can simply make use of that. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35812>
This commit is contained in:
@@ -84,6 +84,19 @@ impl PipeResource {
|
||||
Some(Self { pipe: res })
|
||||
}
|
||||
|
||||
/// Creates a new reference to the underlying GPU resource
|
||||
pub fn new_ref(&self) -> Self {
|
||||
let mut ptr = ptr::null_mut();
|
||||
// SAFETY: pipe_resource_reference will copy the ptr from src to dest, therefore ptr can't
|
||||
// be NULL.
|
||||
unsafe {
|
||||
pipe_resource_reference(&mut ptr, self.pipe.as_ptr());
|
||||
Self {
|
||||
pipe: NonNull::new_unchecked(ptr),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn pipe(&self) -> *mut pipe_resource {
|
||||
self.pipe.as_ptr()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user