rusticl: add a safe abstraction to execute a ProgramCB
Reviewed-by: Karol Herbst <kherbst@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25669>
This commit is contained in:
parent
b1b0ca1acb
commit
0b9c926dd2
2 changed files with 14 additions and 6 deletions
|
|
@ -289,7 +289,7 @@ fn build_program(
|
|||
}
|
||||
|
||||
if let Some(cb) = cb_opt {
|
||||
unsafe { (cb.func)(program, cb.data) };
|
||||
cb.call(p);
|
||||
}
|
||||
|
||||
//• CL_INVALID_BINARY if program is created with clCreateProgramWithBinary and devices listed in device_list do not have a valid program binary loaded.
|
||||
|
|
@ -375,7 +375,7 @@ fn compile_program(
|
|||
}
|
||||
|
||||
if let Some(cb) = cb_opt {
|
||||
unsafe { (cb.func)(program, cb.data) };
|
||||
cb.call(p);
|
||||
}
|
||||
|
||||
// • CL_INVALID_COMPILER_OPTIONS if the compiler options specified by options are invalid.
|
||||
|
|
@ -447,13 +447,11 @@ pub fn link_program(
|
|||
CL_LINK_PROGRAM_FAILURE
|
||||
};
|
||||
|
||||
let res = cl_program::from_arc(res);
|
||||
|
||||
if let Some(cb) = cb_opt {
|
||||
unsafe { (cb.func)(res, cb.data) };
|
||||
cb.call(&res);
|
||||
}
|
||||
|
||||
Ok((res, code))
|
||||
Ok((cl_program::from_arc(res), 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.
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ use crate::api::icd::ReferenceCountedAPIPointer;
|
|||
use crate::core::context::Context;
|
||||
use crate::core::event::Event;
|
||||
use crate::core::memory::Mem;
|
||||
use crate::core::program::Program;
|
||||
use crate::core::queue::Queue;
|
||||
|
||||
use rusticl_opencl_gen::*;
|
||||
|
|
@ -178,6 +179,15 @@ cl_callback!(
|
|||
}
|
||||
);
|
||||
|
||||
impl ProgramCB {
|
||||
pub fn call(self, program: &Program) {
|
||||
let cl = cl_program::from_ptr(program);
|
||||
// SAFETY: `cl` must have pointed to an OpenCL program, which is where we just got it from.
|
||||
// All other requirements are covered by this callback's type invariants.
|
||||
unsafe { (self.func)(cl, self.data) };
|
||||
}
|
||||
}
|
||||
|
||||
cl_callback!(
|
||||
SVMFreeCb(FuncSVMFreeCb) {
|
||||
queue: cl_command_queue,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue