diff --git a/src/gallium/frontends/rusticl/api/device.rs b/src/gallium/frontends/rusticl/api/device.rs index 3f0c8c767ab..33b86c88ac8 100644 --- a/src/gallium/frontends/rusticl/api/device.rs +++ b/src/gallium/frontends/rusticl/api/device.rs @@ -144,7 +144,7 @@ impl CLInfo for cl_device_id { CL_DEVICE_PRINTF_BUFFER_SIZE => cl_prop::(dev.printf_buffer_size()), // TODO CL_DEVICE_PROFILING_TIMER_RESOLUTION => cl_prop::(0), - CL_DEVICE_OPENCL_C_FEATURES => cl_prop::>(Vec::new()), + CL_DEVICE_OPENCL_C_FEATURES => cl_prop::<&Vec>(&dev.clc_features), CL_DEVICE_OPENCL_C_VERSION => { cl_prop::(format!("OpenCL C {} ", dev.clc_version.api_str())) } diff --git a/src/gallium/frontends/rusticl/core/device.rs b/src/gallium/frontends/rusticl/core/device.rs index 13f6d98bf43..c7246f9529a 100644 --- a/src/gallium/frontends/rusticl/core/device.rs +++ b/src/gallium/frontends/rusticl/core/device.rs @@ -41,6 +41,7 @@ pub struct Device { pub embedded: bool, pub extension_string: String, pub extensions: Vec, + pub clc_features: Vec, pub formats: HashMap>, pub lib_clc: NirShader, helper_ctx: Mutex, @@ -127,6 +128,7 @@ impl Device { embedded: false, extension_string: String::from(""), extensions: Vec::new(), + clc_features: Vec::new(), formats: HashMap::new(), lib_clc: lib_clc?, }; @@ -387,39 +389,57 @@ impl Device { fn fill_extensions(&mut self) { let mut exts_str: Vec = Vec::new(); let mut exts = Vec::new(); - let mut add_ext = |major, minor, patch, ext| { - exts.push(mk_cl_version_ext(major, minor, patch, ext)); - exts_str.push(ext.to_owned()); + let mut feats = Vec::new(); + let mut add_ext = |major, minor, patch, ext: &str, feat: &str| { + if !ext.is_empty() { + exts.push(mk_cl_version_ext(major, minor, patch, ext)); + exts_str.push(ext.to_owned()); + } + + if !feat.is_empty() { + feats.push(mk_cl_version_ext(major, minor, patch, feat)); + } }; // add extensions all drivers support - add_ext(1, 0, 0, "cl_khr_byte_addressable_store"); - add_ext(1, 0, 0, "cl_khr_global_int32_base_atomics"); - add_ext(1, 0, 0, "cl_khr_global_int32_extended_atomics"); - add_ext(1, 0, 0, "cl_khr_local_int32_base_atomics"); - add_ext(1, 0, 0, "cl_khr_local_int32_extended_atomics"); + add_ext(1, 0, 0, "cl_khr_byte_addressable_store", ""); + add_ext(1, 0, 0, "cl_khr_global_int32_base_atomics", ""); + add_ext(1, 0, 0, "cl_khr_global_int32_extended_atomics", ""); + add_ext(1, 0, 0, "cl_khr_local_int32_base_atomics", ""); + add_ext(1, 0, 0, "cl_khr_local_int32_extended_atomics", ""); if self.doubles_supported() { - add_ext(1, 0, 0, "cl_khr_fp64"); + add_ext(1, 0, 0, "cl_khr_fp64", "__opencl_c_fp64"); } - if !FORMATS - .iter() - .filter(|f| f.req_for_3d_image_write_ext) - .map(|f| self.formats.get(&f.cl_image_format).unwrap()) - .map(|f| f.get(&CL_MEM_OBJECT_IMAGE3D).unwrap()) - .any(|f| *f & cl_mem_flags::from(CL_MEM_WRITE_ONLY) == 0) - { - add_ext(1, 0, 0, "cl_khr_3d_image_writes"); + if self.long_supported() { + let ext = if self.embedded { "cles_khr_int64" } else { "" }; + + add_ext(1, 0, 0, ext, "__opencl_c_int64"); } - if self.embedded { - if self.long_supported() { - add_ext(1, 0, 0, "cles_khr_int64"); + if self.image_supported() { + add_ext(1, 0, 0, "", "__opencl_c_images"); + + if !FORMATS + .iter() + .filter(|f| f.req_for_3d_image_write_ext) + .map(|f| self.formats.get(&f.cl_image_format).unwrap()) + .map(|f| f.get(&CL_MEM_OBJECT_IMAGE3D).unwrap()) + .any(|f| *f & cl_mem_flags::from(CL_MEM_WRITE_ONLY) == 0) + { + add_ext( + 1, + 0, + 0, + "cl_khr_3d_image_writes", + "__opencl_c_3d_image_writes", + ); } } self.extensions = exts; + self.clc_features = feats; self.extension_string = exts_str.join(" "); }