From 379e72e7eda498cefe033eb02fe494e12eac7d2e Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Wed, 27 Nov 2024 10:59:32 +0100 Subject: [PATCH] rusticl/program: use write_len_only for CL_PROGRAM_IL The spec mandates that if the program object isn't created from IL, it should not touch the buffer. Passing an empty slice would achieve that, but it's better to be explicit here. Reviewed-by: @LingMan Part-of: --- src/gallium/frontends/rusticl/api/program.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gallium/frontends/rusticl/api/program.rs b/src/gallium/frontends/rusticl/api/program.rs index 488ddd9411c..5c4ecc5d61f 100644 --- a/src/gallium/frontends/rusticl/api/program.rs +++ b/src/gallium/frontends/rusticl/api/program.rs @@ -48,10 +48,11 @@ unsafe impl CLInfo for cl_program { CL_PROGRAM_DEVICES => { v.write_iter::(prog.devs.iter().map(|&d| cl_device_id::from_ptr(d))) } - CL_PROGRAM_IL => v.write::<&[u8]>(match &prog.src { - ProgramSourceType::Il(il) => il.to_bin(), - _ => &[], - }), + CL_PROGRAM_IL => match &prog.src { + ProgramSourceType::Il(il) => v.write::<&[u8]>(il.to_bin()), + // The spec _requires_ that we don't touch the buffer here. + _ => v.write_len_only::<&[u8]>(0), + }, CL_PROGRAM_KERNEL_NAMES => v.write::<&str>(&prog.build_info().kernels().join(";")), CL_PROGRAM_NUM_DEVICES => v.write::(prog.devs.len() as cl_uint), CL_PROGRAM_NUM_KERNELS => v.write::(prog.build_info().kernels().len()),