rusticl/kernel: more clGetKernelWorkGroupInfo props

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:
Karol Herbst 2022-03-16 15:52:40 +01:00 committed by Marge Bot
parent 5795ee0e08
commit ea02dfce88
3 changed files with 17 additions and 2 deletions

View file

@ -64,10 +64,12 @@ impl CLInfoObj<cl_kernel_arg_info, cl_uint> for cl_kernel {
impl CLInfoObj<cl_kernel_work_group_info, cl_device_id> for cl_kernel {
fn query(&self, dev: cl_device_id, q: cl_kernel_work_group_info) -> CLResult<Vec<u8>> {
let _kernel = self.get_ref()?;
let _dev = dev.get_ref()?;
let kernel = self.get_ref()?;
let dev = dev.get_arc()?;
Ok(match *q {
CL_KERNEL_LOCAL_MEM_SIZE => cl_prop::<cl_ulong>(kernel.local_mem_size(&dev)),
CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE => cl_prop::<usize>(1),
CL_KERNEL_PRIVATE_MEM_SIZE => cl_prop::<cl_ulong>(kernel.priv_mem_size(&dev)),
// TODO
CL_KERNEL_WORK_GROUP_SIZE => cl_prop::<usize>(1),
// CL_INVALID_VALUE if param_name is not one of the supported values

View file

@ -486,4 +486,13 @@ impl Kernel {
pub fn arg_type_name(&self, idx: cl_uint) -> &String {
&self.args[idx as usize].spirv.type_name
}
pub fn priv_mem_size(&self, dev: &Arc<Device>) -> cl_ulong {
self.nirs.get(dev).unwrap().scratch_size() as cl_ulong
}
pub fn local_mem_size(&self, dev: &Arc<Device>) -> cl_ulong {
// TODO include args
self.nirs.get(dev).unwrap().shared_size() as cl_ulong
}
}

View file

@ -144,6 +144,10 @@ impl NirShader {
}
}
pub fn scratch_size(&self) -> u32 {
unsafe { (*self.nir.as_ptr()).scratch_size }
}
pub fn shared_size(&self) -> u32 {
unsafe { (*self.nir.as_ptr()).info.shared_size }
}