From 2a0b58434d850f77da13432c2a7259d8f21636aa Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Mon, 13 Feb 2023 12:04:10 +0100 Subject: [PATCH] rusticl/kernel: fix clGetKernelInfo CL_KERNEL_ATTRIBUTES for non source programs Signed-off-by: Karol Herbst Part-of: --- src/gallium/frontends/rusticl/core/kernel.rs | 9 ++++++++- src/gallium/frontends/rusticl/core/program.rs | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/gallium/frontends/rusticl/core/kernel.rs b/src/gallium/frontends/rusticl/core/kernel.rs index 2d35682fc43..f1dde309fa2 100644 --- a/src/gallium/frontends/rusticl/core/kernel.rs +++ b/src/gallium/frontends/rusticl/core/kernel.rs @@ -803,7 +803,14 @@ fn convert_spirv_to_nir( assert!(attributes_string_set.len() == 1); let args = args_set.into_iter().next().unwrap(); let internal_args = internal_args_set.into_iter().next().unwrap(); - let attributes_string = attributes_string_set.into_iter().next().unwrap(); + + // spec: For kernels not created from OpenCL C source and the clCreateProgramWithSource API call + // the string returned from this query [CL_KERNEL_ATTRIBUTES] will be empty. + let attributes_string = if p.is_src() { + attributes_string_set.into_iter().next().unwrap() + } else { + String::new() + }; (nirs, args, internal_args, attributes_string) } diff --git a/src/gallium/frontends/rusticl/core/program.rs b/src/gallium/frontends/rusticl/core/program.rs index 15c4a773d6a..42d2f8a8415 100644 --- a/src/gallium/frontends/rusticl/core/program.rs +++ b/src/gallium/frontends/rusticl/core/program.rs @@ -591,4 +591,8 @@ impl Program { pub fn is_binary(&self) -> bool { self.src.to_bytes().is_empty() && self.il.is_empty() } + + pub fn is_src(&self) -> bool { + !self.src.to_bytes().is_empty() + } }