mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 18:18:06 +02:00
rusticl/mesa: make PipeResource repr(transparent)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30082>
This commit is contained in:
parent
a382fb08a4
commit
51e56c6c7b
3 changed files with 17 additions and 8 deletions
|
|
@ -81,7 +81,7 @@ impl Context {
|
|||
|
||||
if !user_ptr.is_null() {
|
||||
res.iter()
|
||||
.filter(|(_, r)| copy || !r.is_user)
|
||||
.filter(|(_, r)| copy || !r.is_user())
|
||||
.map(|(d, r)| {
|
||||
d.helper_ctx()
|
||||
.exec(|ctx| ctx.buffer_subdata(r, 0, user_ptr, size.try_into().unwrap()))
|
||||
|
|
@ -163,7 +163,7 @@ impl Context {
|
|||
let layer_stride = desc.slice_pitch();
|
||||
|
||||
res.iter()
|
||||
.filter(|(_, r)| copy || !r.is_user)
|
||||
.filter(|(_, r)| copy || !r.is_user())
|
||||
.map(|(d, r)| {
|
||||
d.helper_ctx()
|
||||
.exec(|ctx| ctx.texture_subdata(r, &bx, user_ptr, stride, layer_stride))
|
||||
|
|
|
|||
|
|
@ -712,7 +712,7 @@ impl MemBase {
|
|||
|
||||
fn is_pure_user_memory(&self, d: &Device) -> CLResult<bool> {
|
||||
let r = self.get_res_of_dev(d)?;
|
||||
Ok(r.is_user)
|
||||
Ok(r.is_user())
|
||||
}
|
||||
|
||||
fn map<T>(
|
||||
|
|
|
|||
|
|
@ -3,11 +3,13 @@ use mesa_rust_gen::*;
|
|||
use std::{mem, ptr};
|
||||
|
||||
#[derive(PartialEq, Eq, Hash)]
|
||||
#[repr(transparent)]
|
||||
pub struct PipeResource {
|
||||
pipe: *mut pipe_resource,
|
||||
pub is_user: bool,
|
||||
}
|
||||
|
||||
const PIPE_RESOURCE_FLAG_RUSTICL_IS_USER: u32 = PIPE_RESOURCE_FLAG_FRONTEND_PRIV;
|
||||
|
||||
// SAFETY: pipe_resource is considered a thread safe type
|
||||
unsafe impl Send for PipeResource {}
|
||||
unsafe impl Sync for PipeResource {}
|
||||
|
|
@ -68,10 +70,13 @@ impl PipeResource {
|
|||
return None;
|
||||
}
|
||||
|
||||
Some(Self {
|
||||
pipe: res,
|
||||
is_user: is_user,
|
||||
})
|
||||
if is_user {
|
||||
unsafe {
|
||||
res.as_mut().unwrap().flags |= PIPE_RESOURCE_FLAG_RUSTICL_IS_USER;
|
||||
}
|
||||
}
|
||||
|
||||
Some(Self { pipe: res })
|
||||
}
|
||||
|
||||
pub(super) fn pipe(&self) -> *mut pipe_resource {
|
||||
|
|
@ -110,6 +115,10 @@ impl PipeResource {
|
|||
self.as_ref().usage() == pipe_resource_usage::PIPE_USAGE_STAGING
|
||||
}
|
||||
|
||||
pub fn is_user(&self) -> bool {
|
||||
self.as_ref().flags & PIPE_RESOURCE_FLAG_RUSTICL_IS_USER != 0
|
||||
}
|
||||
|
||||
pub fn pipe_image_view(
|
||||
&self,
|
||||
format: pipe_format,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue