rusticl: implement CL 3.1 device features

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41358>
This commit is contained in:
Karol Herbst 2026-03-02 02:05:35 +01:00 committed by Marge Bot
parent 626ec83855
commit 47dca06b2e
3 changed files with 27 additions and 4 deletions

View file

@ -12,3 +12,4 @@ VK_EXT_pipeline_protected_access on RADV
VK_EXT_extended_dynamic_state3 on panvk
GL_ARB_texture_query_lod on panfrost/v9+
VK_KHR_maintenance11 on RADV
OpenCL 3.1 support for rusticl on asahi, iris, radeonsi, llvmpipe and zink

View file

@ -497,7 +497,17 @@ impl DeviceBase {
// TODO add CLC checks
fn check_version(&mut self) {
let exts: Vec<&str> = self.extension_string.split(' ').collect();
let mut res = CLVersion::Cl3_0;
let mut res = CLVersion::Cl3_1;
// CL 3.1 requires a bit more than we check here, but those are all features we support on
// every device anyway.
if !self.subgroup_shuffle_supported()
|| !self.subgroup_shuffle_relative_supported()
|| !self.subgroup_rotate_supported()
|| !self.uuid_supported()
{
res = CLVersion::Cl3_0;
}
#[allow(clippy::collapsible_if)]
if self.embedded {
@ -561,6 +571,11 @@ impl DeviceBase {
res = val;
}
if res >= CLVersion::Cl3_1 {
self.clc_versions
.push(mk_cl_version_ext(3, 1, 0, "OpenCL C"));
}
if res >= CLVersion::Cl3_0 {
self.clc_versions
.push(mk_cl_version_ext(3, 0, 0, "OpenCL C"));
@ -732,7 +747,7 @@ impl DeviceBase {
add_ext(1, 0, 0, "cl_khr_priority_hints");
}
if self.screen().device_uuid().is_some() && self.screen().driver_uuid().is_some() {
if self.uuid_supported() {
static_assert!(PIPE_UUID_SIZE == CL_UUID_SIZE_KHR);
static_assert!(PIPE_LUID_SIZE == CL_LUID_SIZE_KHR);
@ -1367,6 +1382,10 @@ impl DeviceBase {
pub fn are_semaphores_supported(&self) -> bool {
self.screen().caps().fence_signal && self.screen().has_semaphore_create()
}
pub fn uuid_supported(&self) -> bool {
self.screen().device_uuid().is_some() && self.screen().driver_uuid().is_some()
}
}
impl Device {
@ -1392,8 +1411,8 @@ impl Device {
caps: DeviceCaps::new(&screen, &helper_ctx),
helper_ctx: Mutex::new(helper_ctx),
screen: screen,
cl_version: CLVersion::Cl3_0,
clc_version: CLVersion::Cl3_0,
cl_version: CLVersion::Cl3_1,
clc_version: CLVersion::Cl3_1,
clc_versions: Vec::new(),
device_type: 0,
embedded: false,

View file

@ -309,6 +309,9 @@ fn prepare_options(options: &str, dev: &Device) -> Vec<CString> {
res.iter()
.filter_map(|&a| match a {
// CL3.1 doesn't add anything that's not already supported in clang, so just replace
// the argument with 3.0 so we'll be fine with an older version of clang.
"-cl-std=CL3.1" => Some("-cl-std=CL3.0"),
"-cl-denorms-are-zero" => Some("-fdenormal-fp-math=positive-zero"),
// We can ignore it as long as we don't support ifp
"-cl-no-subgroup-ifp" => None,