mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-26 23:40:10 +01:00
rusticl/icd: move from_arc() and rename it
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27376>
This commit is contained in:
parent
51afd7a00c
commit
57e5d377da
7 changed files with 24 additions and 42 deletions
|
|
@ -193,11 +193,7 @@ fn create_context(
|
|||
}
|
||||
}
|
||||
|
||||
Ok(cl_context::from_arc(Context::new(
|
||||
devs,
|
||||
props,
|
||||
gl_ctx_manager,
|
||||
)))
|
||||
Ok(Context::new(devs, props, gl_ctx_manager).into_cl())
|
||||
}
|
||||
|
||||
#[cl_entrypoint]
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ impl CLInfo<cl_profiling_info> for cl_event {
|
|||
#[cl_entrypoint]
|
||||
fn create_user_event(context: cl_context) -> CLResult<cl_event> {
|
||||
let c = context.get_arc()?;
|
||||
Ok(cl_event::from_arc(Event::new_user(c)))
|
||||
Ok(Event::new_user(c).into_cl())
|
||||
}
|
||||
|
||||
#[cl_entrypoint]
|
||||
|
|
@ -165,7 +165,7 @@ pub fn create_and_queue(
|
|||
if !event.is_null() {
|
||||
// SAFETY: we check for null and valid API use is to pass in a valid pointer
|
||||
unsafe {
|
||||
event.write(cl_event::from_arc(Arc::clone(&e)));
|
||||
event.write(Arc::clone(&e).into_cl());
|
||||
}
|
||||
}
|
||||
q.queue(e);
|
||||
|
|
|
|||
|
|
@ -241,13 +241,6 @@ pub trait ReferenceCountedAPIPointer<T, const ERR: i32> {
|
|||
Ok(Arc::from_raw(ptr))
|
||||
}
|
||||
}
|
||||
|
||||
fn from_arc(arc: Arc<T>) -> Self
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
Self::from_ptr(Arc::into_raw(arc))
|
||||
}
|
||||
}
|
||||
|
||||
pub trait CLObject<'a, const ERR: i32, CL: ReferenceCountedAPIPointer<Self, ERR> + 'a>:
|
||||
|
|
@ -321,6 +314,10 @@ pub trait CLObject<'a, const ERR: i32, CL: ReferenceCountedAPIPointer<Self, ERR>
|
|||
unsafe { Arc::increment_strong_count(ptr) };
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn into_cl(self: Arc<Self>) -> CL {
|
||||
CL::from_ptr(Arc::into_raw(self))
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@ fn create_kernel(
|
|||
return Err(CL_INVALID_KERNEL_DEFINITION);
|
||||
}
|
||||
|
||||
Ok(cl_kernel::from_arc(Kernel::new(name, p)))
|
||||
Ok(Kernel::new(name, p).into_cl())
|
||||
}
|
||||
|
||||
#[cl_entrypoint]
|
||||
|
|
@ -311,7 +311,7 @@ fn create_kernels_in_program(
|
|||
unsafe {
|
||||
kernels
|
||||
.add(num_kernels as usize)
|
||||
.write(cl_kernel::from_arc(Kernel::new(name, p.clone())));
|
||||
.write(Kernel::new(name, p.clone()).into_cl());
|
||||
}
|
||||
}
|
||||
num_kernels += 1;
|
||||
|
|
@ -645,5 +645,5 @@ fn enqueue_task(
|
|||
#[cl_entrypoint]
|
||||
fn clone_kernel(source_kernel: cl_kernel) -> CLResult<cl_kernel> {
|
||||
let k = Kernel::ref_from_raw(source_kernel)?;
|
||||
Ok(cl_kernel::from_arc(Arc::new(k.clone())))
|
||||
Ok(Arc::new(k.clone()).into_cl())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -280,9 +280,7 @@ fn create_buffer_with_properties(
|
|||
return Err(CL_INVALID_PROPERTY);
|
||||
}
|
||||
|
||||
Ok(cl_mem::from_arc(Mem::new_buffer(
|
||||
c, flags, size, host_ptr, props,
|
||||
)?))
|
||||
Ok(Mem::new_buffer(c, flags, size, host_ptr, props)?.into_cl())
|
||||
}
|
||||
|
||||
#[cl_entrypoint]
|
||||
|
|
@ -341,9 +339,7 @@ fn create_sub_buffer(
|
|||
_ => return Err(CL_INVALID_VALUE),
|
||||
};
|
||||
|
||||
Ok(cl_mem::from_arc(Mem::new_sub_buffer(
|
||||
b, flags, offset, size,
|
||||
)))
|
||||
Ok(Mem::new_sub_buffer(b, flags, offset, size).into_cl())
|
||||
|
||||
// TODO
|
||||
// CL_MISALIGNED_SUB_BUFFER_OFFSET if there are no devices in context associated with buffer for which the origin field of the cl_buffer_region structure passed in buffer_create_info is aligned to the CL_DEVICE_MEM_BASE_ADDR_ALIGN value.
|
||||
|
|
@ -773,7 +769,7 @@ fn create_image_with_properties(
|
|||
return Err(CL_INVALID_PROPERTY);
|
||||
}
|
||||
|
||||
Ok(cl_mem::from_arc(Mem::new_image(
|
||||
Ok(Mem::new_image(
|
||||
c,
|
||||
parent,
|
||||
desc.image_type,
|
||||
|
|
@ -783,7 +779,8 @@ fn create_image_with_properties(
|
|||
elem_size,
|
||||
host_ptr,
|
||||
props,
|
||||
)?))
|
||||
)?
|
||||
.into_cl())
|
||||
}
|
||||
|
||||
#[cl_entrypoint]
|
||||
|
|
@ -946,7 +943,7 @@ fn create_sampler_impl(
|
|||
filter_mode,
|
||||
props,
|
||||
);
|
||||
Ok(cl_sampler::from_arc(sampler))
|
||||
Ok(sampler.into_cl())
|
||||
}
|
||||
|
||||
#[cl_entrypoint]
|
||||
|
|
@ -3008,11 +3005,7 @@ fn create_from_gl(
|
|||
let gl_export_manager =
|
||||
gl_ctx_manager.export_object(&c, target, flags as u32, miplevel, texture)?;
|
||||
|
||||
Ok(cl_mem::from_arc(Mem::from_gl(
|
||||
c,
|
||||
flags,
|
||||
&gl_export_manager,
|
||||
)?))
|
||||
Ok(Mem::from_gl(c, flags, &gl_export_manager)?.into_cl())
|
||||
} else {
|
||||
Err(CL_INVALID_CONTEXT)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,12 +163,13 @@ fn create_program_with_source(
|
|||
source.extend_from_slice(arr);
|
||||
}
|
||||
|
||||
Ok(cl_program::from_arc(Program::new(
|
||||
Ok(Program::new(
|
||||
&c,
|
||||
&c.devs,
|
||||
// SAFETY: We've constructed `source` such that it contains no nul bytes.
|
||||
unsafe { CString::from_vec_unchecked(source) },
|
||||
)))
|
||||
)
|
||||
.into_cl())
|
||||
}
|
||||
|
||||
#[cl_entrypoint]
|
||||
|
|
@ -228,7 +229,7 @@ fn create_program_with_binary(
|
|||
|
||||
let prog = Program::from_bins(c, devs, &bins);
|
||||
|
||||
Ok(cl_program::from_arc(prog))
|
||||
Ok(prog.into_cl())
|
||||
//• CL_INVALID_BINARY if an invalid program binary was encountered for any device. binary_status will return specific status for each device.
|
||||
}
|
||||
|
||||
|
|
@ -247,7 +248,7 @@ fn create_program_with_il(
|
|||
|
||||
// SAFETY: according to API spec
|
||||
let spirv = unsafe { slice::from_raw_parts(il.cast(), length) };
|
||||
Ok(cl_program::from_arc(Program::from_spirv(c, spirv)))
|
||||
Ok(Program::from_spirv(c, spirv).into_cl())
|
||||
}
|
||||
|
||||
#[cl_entrypoint]
|
||||
|
|
@ -455,7 +456,7 @@ pub fn link_program(
|
|||
}
|
||||
|
||||
debug_logging(&res, &devs);
|
||||
Ok((cl_program::from_arc(res), code))
|
||||
Ok((res.into_cl(), code))
|
||||
|
||||
//• CL_INVALID_LINKER_OPTIONS if the linker options specified by options are invalid.
|
||||
//• CL_INVALID_OPERATION if the rules for devices containing compiled binaries or libraries as described in input_programs argument above are not followed.
|
||||
|
|
|
|||
|
|
@ -93,12 +93,7 @@ pub fn create_command_queue_impl(
|
|||
return Err(CL_INVALID_QUEUE_PROPERTIES);
|
||||
}
|
||||
|
||||
Ok(cl_command_queue::from_arc(Queue::new(
|
||||
c,
|
||||
d,
|
||||
properties,
|
||||
properties_v2,
|
||||
)?))
|
||||
Ok(Queue::new(c, d, properties, properties_v2)?.into_cl())
|
||||
}
|
||||
|
||||
#[cl_entrypoint]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue