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: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32268>
This commit is contained in:
Karol Herbst 2024-11-27 10:59:32 +01:00 committed by Marge Bot
parent 69fd3a33dc
commit 379e72e7ed

View file

@ -48,10 +48,11 @@ unsafe impl CLInfo<cl_program_info> for cl_program {
CL_PROGRAM_DEVICES => {
v.write_iter::<cl_device_id>(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::<cl_uint>(prog.devs.len() as cl_uint),
CL_PROGRAM_NUM_KERNELS => v.write::<usize>(prog.build_info().kernels().len()),