mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 04:38:03 +02:00
rusticl/icd: move get_arc_vec_from_arr and rename it
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27376>
This commit is contained in:
parent
9b5bcbb60f
commit
4ca11d5f06
4 changed files with 10 additions and 13 deletions
|
|
@ -78,7 +78,7 @@ fn release_event(event: cl_event) -> CLResult<()> {
|
|||
|
||||
#[cl_entrypoint]
|
||||
fn wait_for_events(num_events: cl_uint, event_list: *const cl_event) -> CLResult<()> {
|
||||
let evs = cl_event::get_arc_vec_from_arr(event_list, num_events)?;
|
||||
let evs = Event::arcs_from_arr(event_list, num_events)?;
|
||||
|
||||
// CL_INVALID_VALUE if num_events is zero or event_list is NULL.
|
||||
if evs.is_empty() {
|
||||
|
|
|
|||
|
|
@ -263,11 +263,12 @@ pub trait ReferenceCountedAPIPointer<T, const ERR: i32> {
|
|||
{
|
||||
Self::from_ptr(Arc::into_raw(arc))
|
||||
}
|
||||
}
|
||||
|
||||
fn get_arc_vec_from_arr(objs: *const Self, count: u32) -> CLResult<Vec<Arc<T>>>
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
pub trait CLObject<'a, const ERR: i32, CL: ReferenceCountedAPIPointer<Self, ERR> + 'a>:
|
||||
Sized
|
||||
{
|
||||
fn arcs_from_arr(objs: *const CL, count: u32) -> CLResult<Vec<Arc<Self>>> {
|
||||
// CL spec requires validation for obj arrays, both values have to make sense
|
||||
if objs.is_null() && count > 0 || !objs.is_null() && count == 0 {
|
||||
return Err(CL_INVALID_VALUE);
|
||||
|
|
@ -285,11 +286,7 @@ pub trait ReferenceCountedAPIPointer<T, const ERR: i32> {
|
|||
}
|
||||
Ok(res)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait CLObject<'a, const ERR: i32, CL: ReferenceCountedAPIPointer<Self, ERR> + 'a>:
|
||||
Sized
|
||||
{
|
||||
fn refcnt(ptr: CL) -> CLResult<u32> {
|
||||
let ptr = ptr.get_ptr()?;
|
||||
// SAFETY: `get_ptr` already checks if it's one of our pointers.
|
||||
|
|
|
|||
|
|
@ -2223,7 +2223,7 @@ fn enqueue_migrate_mem_objects(
|
|||
) -> CLResult<()> {
|
||||
let q = command_queue.get_arc()?;
|
||||
let evs = event_list_from_cl(&q, num_events_in_wait_list, event_wait_list)?;
|
||||
let bufs = cl_mem::get_arc_vec_from_arr(mem_objects, num_mem_objects)?;
|
||||
let bufs = Mem::arcs_from_arr(mem_objects, num_mem_objects)?;
|
||||
|
||||
// CL_INVALID_VALUE if num_mem_objects is zero or if mem_objects is NULL.
|
||||
if bufs.is_empty() {
|
||||
|
|
@ -3120,7 +3120,7 @@ fn enqueue_acquire_gl_objects(
|
|||
) -> CLResult<()> {
|
||||
let q = command_queue.get_arc()?;
|
||||
let evs = event_list_from_cl(&q, num_events_in_wait_list, event_wait_list)?;
|
||||
let objs = cl_mem::get_arc_vec_from_arr(mem_objects, num_objects)?;
|
||||
let objs = Mem::arcs_from_arr(mem_objects, num_objects)?;
|
||||
let gl_ctx_manager = &q.context.gl_ctx_manager;
|
||||
|
||||
// CL_INVALID_CONTEXT if context associated with command_queue was not created from an OpenGL context
|
||||
|
|
@ -3154,7 +3154,7 @@ fn enqueue_release_gl_objects(
|
|||
) -> CLResult<()> {
|
||||
let q = command_queue.get_arc()?;
|
||||
let evs = event_list_from_cl(&q, num_events_in_wait_list, event_wait_list)?;
|
||||
let objs = cl_mem::get_arc_vec_from_arr(mem_objects, num_objects)?;
|
||||
let objs = Mem::arcs_from_arr(mem_objects, num_objects)?;
|
||||
let gl_ctx_manager = &q.context.gl_ctx_manager;
|
||||
|
||||
// CL_INVALID_CONTEXT if context associated with command_queue was not created from an OpenGL context
|
||||
|
|
|
|||
|
|
@ -408,7 +408,7 @@ pub fn link_program(
|
|||
) -> CLResult<(cl_program, cl_int)> {
|
||||
let c = context.get_arc()?;
|
||||
let devs = validate_devices(device_list, num_devices, &c.devs)?;
|
||||
let progs = cl_program::get_arc_vec_from_arr(input_programs, num_input_programs)?;
|
||||
let progs = Program::arcs_from_arr(input_programs, num_input_programs)?;
|
||||
|
||||
// SAFETY: The requirements on `ProgramCB::try_new` match the requirements
|
||||
// imposed by the OpenCL specification. It is the caller's duty to uphold them.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue