mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 22:38:05 +02:00
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:
parent
ff0d77d69d
commit
900dacb0ef
1 changed files with 13 additions and 0 deletions
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue