diff --git a/src/gallium/frontends/rusticl/api/program.rs b/src/gallium/frontends/rusticl/api/program.rs index 93ab2a69ce7..f58721d8ef2 100644 --- a/src/gallium/frontends/rusticl/api/program.rs +++ b/src/gallium/frontends/rusticl/api/program.rs @@ -28,11 +28,16 @@ unsafe impl CLInfo for cl_program { match q { CL_PROGRAM_BINARIES => { let input = v.input::<*mut u8>()?; - // SAFETY: Oer spec it contains an array of pointers to write the binaries to, - // so we can assume the entire slice to be initialized. - let input = unsafe { slice_assume_init_ref(input) }; - let bins = prog.binaries(input)?; - v.write::>(bins) + // This query is a bit weird. At least the CTS is. We need to return the proper size + // of the buffer to hold all pointers, but when actually doing the query, we'd just + // parse the pointers out and write to them. + if !input.is_empty() { + // SAFETY: Per spec it contains an array of pointers to write the binaries to, + // so we can assume the entire slice to be initialized. + let input = unsafe { slice_assume_init_ref(input) }; + prog.binaries(input)?; + } + v.write_len_only::<&[*mut u8]>(prog.devs.len()) } CL_PROGRAM_BINARY_SIZES => v.write::>(prog.bin_sizes()), CL_PROGRAM_CONTEXT => { diff --git a/src/gallium/frontends/rusticl/core/program.rs b/src/gallium/frontends/rusticl/core/program.rs index 6e9488a5ce5..a493f0e2f55 100644 --- a/src/gallium/frontends/rusticl/core/program.rs +++ b/src/gallium/frontends/rusticl/core/program.rs @@ -477,12 +477,7 @@ impl Program { res } - pub fn binaries(&self, ptrs: &[*mut u8]) -> CLResult> { - // if the application didn't provide any pointers, just return the length of devices - if ptrs.is_empty() { - return Ok(vec![std::ptr::null_mut(); self.devs.len()]); - } - + pub fn binaries(&self, ptrs: &[*mut u8]) -> CLResult<()> { // ptrs is an array of pointers where we should write the device binaries into if ptrs.len() < self.devs.len() { return Err(CL_INVALID_VALUE); @@ -531,7 +526,7 @@ impl Program { } } - Ok(ptrs.to_vec()) + Ok(()) } // TODO: at the moment we do not support compiling programs with different signatures across