mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-29 21:00:16 +01:00
rusticl/kernel: implement clCloneKernel
Signed-off-by: Karol Herbst <kherbst@redhat.com> Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15439>
This commit is contained in:
parent
e1fefd5372
commit
a40d4c0346
5 changed files with 39 additions and 5 deletions
|
|
@ -159,7 +159,7 @@ pub static DISPATCH: cl_icd_dispatch = cl_icd_dispatch {
|
|||
clSetKernelArgSVMPointer: None,
|
||||
clSetKernelExecInfo: None,
|
||||
clGetKernelSubGroupInfoKHR: None,
|
||||
clCloneKernel: None,
|
||||
clCloneKernel: Some(cl_clone_kernel),
|
||||
clCreateProgramWithIL: None,
|
||||
clEnqueueSVMMigrateMem: None,
|
||||
clGetDeviceAndHostTimer: None,
|
||||
|
|
@ -1503,6 +1503,10 @@ extern "C" fn cl_create_command_queue_with_properties(
|
|||
match_obj!(create_command_queue(context, device, 0), errcode_ret)
|
||||
}
|
||||
|
||||
extern "C" fn cl_clone_kernel(source_kernel: cl_kernel, errcode_ret: *mut cl_int) -> cl_kernel {
|
||||
match_obj!(clone_kernel(source_kernel), errcode_ret)
|
||||
}
|
||||
|
||||
extern "C" fn cl_set_context_destructor_callback(
|
||||
context: cl_context,
|
||||
pfn_notify: ::std::option::Option<DeleteContextCB>,
|
||||
|
|
|
|||
|
|
@ -420,3 +420,8 @@ pub fn enqueue_task(
|
|||
event,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn clone_kernel(source_kernel: cl_kernel) -> CLResult<cl_kernel> {
|
||||
let k = source_kernel.get_ref()?;
|
||||
Ok(cl_kernel::from_arc(Arc::new(k.clone())))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ use std::ptr;
|
|||
use std::sync::Arc;
|
||||
|
||||
// ugh, we are not allowed to take refs, so...
|
||||
#[derive(Clone)]
|
||||
pub enum KernelArgValue {
|
||||
None,
|
||||
Constant(Vec<u8>),
|
||||
|
|
@ -32,7 +33,7 @@ pub enum KernelArgValue {
|
|||
LocalMem(usize),
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
#[derive(PartialEq, Eq, Clone)]
|
||||
pub enum KernelArgType {
|
||||
Constant, // for anything passed by value
|
||||
Sampler,
|
||||
|
|
@ -41,12 +42,13 @@ pub enum KernelArgType {
|
|||
MemLocal,
|
||||
}
|
||||
|
||||
#[derive(Hash, PartialEq, Eq)]
|
||||
#[derive(Hash, PartialEq, Eq, Clone)]
|
||||
pub enum InternalKernelArgType {
|
||||
ConstantBuffer,
|
||||
GlobalWorkOffsets,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct KernelArg {
|
||||
spirv: spirv::SPIRVKernelArg,
|
||||
pub kind: KernelArgType,
|
||||
|
|
@ -55,7 +57,7 @@ pub struct KernelArg {
|
|||
pub dead: bool,
|
||||
}
|
||||
|
||||
#[derive(Hash, PartialEq, Eq)]
|
||||
#[derive(Hash, PartialEq, Eq, Clone)]
|
||||
pub struct InternalKernelArg {
|
||||
pub kind: InternalKernelArgType,
|
||||
pub size: usize,
|
||||
|
|
@ -541,3 +543,18 @@ impl Kernel {
|
|||
self.nirs.get(dev).unwrap().shared_size() as cl_ulong
|
||||
}
|
||||
}
|
||||
|
||||
impl Clone for Kernel {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
base: CLObjectBase::new(),
|
||||
prog: self.prog.clone(),
|
||||
name: self.name.clone(),
|
||||
args: self.args.clone(),
|
||||
values: self.values.clone(),
|
||||
work_group_size: self.work_group_size,
|
||||
internal_args: self.internal_args.clone(),
|
||||
nirs: self.nirs.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ pub struct SPIRVBin {
|
|||
info: Option<clc_parsed_spirv>,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Hash)]
|
||||
#[derive(PartialEq, Eq, Hash, Clone)]
|
||||
pub struct SPIRVKernelArg {
|
||||
pub name: String,
|
||||
pub type_name: String,
|
||||
|
|
|
|||
|
|
@ -218,6 +218,14 @@ impl NirShader {
|
|||
}
|
||||
}
|
||||
|
||||
impl Clone for NirShader {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
nir: NonNull::new(self.dup_for_driver()).unwrap(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for NirShader {
|
||||
fn drop(&mut self) {
|
||||
unsafe { ralloc_free(self.nir.as_ptr().cast()) };
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue