diff --git a/src/gallium/frontends/rusticl/api/device.rs b/src/gallium/frontends/rusticl/api/device.rs index 8329b88e390..d0a38ba9b5b 100644 --- a/src/gallium/frontends/rusticl/api/device.rs +++ b/src/gallium/frontends/rusticl/api/device.rs @@ -198,7 +198,7 @@ impl CLInfo for cl_device_id { CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE => { cl_prop::(16 * size_of::() as cl_uint) } - CL_DEVICE_NAME => cl_prop::<&str>(&dev.screen().name()), + CL_DEVICE_NAME => cl_prop::<&CStr>(dev.screen().name()), CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR => cl_prop::(1), CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE => cl_prop::(dev.fp64_supported().into()), CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT => cl_prop::(1), @@ -299,7 +299,7 @@ impl CLInfo for cl_device_id { CL_DEVICE_UUID_KHR => cl_prop::<[cl_uchar; CL_UUID_SIZE_KHR as usize]>( dev.screen().device_uuid().unwrap_or_default(), ), - CL_DEVICE_VENDOR => cl_prop::<&str>(&dev.screen().device_vendor()), + CL_DEVICE_VENDOR => cl_prop::<&CStr>(dev.screen().device_vendor()), CL_DEVICE_VENDOR_ID => cl_prop::(dev.vendor_id()), CL_DEVICE_VERSION => cl_prop::<&str>(&format!("OpenCL {} ", dev.cl_version.api_str())), CL_DRIVER_UUID_KHR => cl_prop::<[cl_char; CL_UUID_SIZE_KHR as usize]>( diff --git a/src/gallium/frontends/rusticl/core/program.rs b/src/gallium/frontends/rusticl/core/program.rs index 4a78a646bbd..2bc99dcebf4 100644 --- a/src/gallium/frontends/rusticl/core/program.rs +++ b/src/gallium/frontends/rusticl/core/program.rs @@ -357,7 +357,7 @@ impl Program { } let name: &[u8] = slice::from_raw_parts(name.cast(), name_length); - if dev.screen().name().as_bytes() != name { + if dev.screen().name().to_bytes() != name { return Err(CL_INVALID_BINARY); } @@ -472,7 +472,7 @@ impl Program { let info = lock.dev_build(d); res.push(info.spirv.as_ref().map_or(0, |s| { - s.to_bin().len() + d.screen().name().as_bytes().len() + BIN_HEADER_SIZE + s.to_bin().len() + d.screen().name().to_bytes().len() + BIN_HEADER_SIZE })); } res @@ -519,7 +519,7 @@ impl Program { blob_write_uint32(&mut blob, 1_u32.to_le()); let device_name = d.screen().name(); - let device_name = device_name.as_bytes(); + let device_name = device_name.to_bytes(); blob_write_uint32(&mut blob, (device_name.len() as u32).to_le()); blob_write_uint32(&mut blob, (spirv.len() as u32).to_le()); diff --git a/src/gallium/frontends/rusticl/mesa/pipe/screen.rs b/src/gallium/frontends/rusticl/mesa/pipe/screen.rs index 524b42b27c7..9c8e4249519 100644 --- a/src/gallium/frontends/rusticl/mesa/pipe/screen.rs +++ b/src/gallium/frontends/rusticl/mesa/pipe/screen.rs @@ -7,7 +7,6 @@ use crate::util::disk_cache::*; use mesa_rust_gen::*; use mesa_rust_util::has_required_feature; use mesa_rust_util::ptr::ThreadSafeCPtr; -use mesa_rust_util::string::*; use std::convert::TryInto; use std::ffi::CStr; @@ -300,8 +299,8 @@ impl PipeScreen { self.ldev.driver_name() } - pub fn name(&self) -> String { - unsafe { c_string_to_string(self.screen().get_name.unwrap()(self.screen.as_ptr())) } + pub fn name(&self) -> &CStr { + unsafe { CStr::from_ptr(self.screen().get_name.unwrap()(self.screen.as_ptr())) } } pub fn device_node_mask(&self) -> Option { @@ -326,9 +325,9 @@ impl PipeScreen { Some(luid) } - pub fn device_vendor(&self) -> String { + pub fn device_vendor(&self) -> &CStr { unsafe { - c_string_to_string(self.screen().get_device_vendor.unwrap()( + CStr::from_ptr(self.screen().get_device_vendor.unwrap()( self.screen.as_ptr(), )) }