rusticl: allow devices to be enabled by default

Reviewed-by: David Heidelberg <david@ixit.cz>
Acked-by: Eric Engestrom <eric@igalia.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31202>
This commit is contained in:
Karol Herbst 2024-09-16 13:29:29 +02:00 committed by Marge Bot
parent 911606081f
commit 1301d61de4
3 changed files with 51 additions and 33 deletions

View file

@ -160,6 +160,14 @@ option(
description : 'build gallium "rusticl" OpenCL frontend.', description : 'build gallium "rusticl" OpenCL frontend.',
) )
option(
'gallium-rusticl-enable-drivers',
type : 'array',
value : ['auto'],
description : 'List of gallium drivers for which rusticl will be enabled ' +
'by default',
)
option( option(
'gallium-wgl-dll-name', 'gallium-wgl-dll-name',
type : 'string', type : 'string',

View file

@ -55,45 +55,48 @@ fn load_devs() -> impl Iterator<Item = PipeLoaderDevice> {
fn get_enabled_devs() -> HashMap<String, u32> { fn get_enabled_devs() -> HashMap<String, u32> {
let mut res = HashMap::new(); let mut res = HashMap::new();
if let Ok(enabled_devs) = env::var("RUSTICL_ENABLE") { // we require the type here as this list can be empty depending on the build options
let mut last_driver = None; let default_devs: &[&str] = &[];
for driver_str in enabled_devs.split(',') {
if driver_str.is_empty() {
continue;
}
// if the string parses to a number, just updated the device bitset // I wished we could use different iterators, but that's not really working out.
if let Ok(dev_id) = driver_str.parse::<u8>() { let enabled_devs = env::var("RUSTICL_ENABLE").unwrap_or(default_devs.join(","));
if let Some(last_driver) = last_driver { let mut last_driver = None;
*res.get_mut(last_driver).unwrap() |= 1 << dev_id; for driver_str in enabled_devs.split(',') {
} if driver_str.is_empty() {
continue; continue;
} else {
let driver_str: Vec<_> = driver_str.split(':').collect();
let mut devices = 0;
if driver_str.len() == 1 {
devices = !0;
} else if let Ok(dev_id) = driver_str[1].parse::<u8>() {
devices |= 1 << dev_id;
}
let driver_str = match driver_str[0] {
"llvmpipe" | "lp" => "swrast",
"freedreno" => "msm",
a => a,
};
res.insert(driver_str.to_owned(), devices);
last_driver = Some(driver_str);
}
} }
if res.contains_key("panfrost") { // if the string parses to a number, just updated the device bitset
res.insert("panthor".to_owned(), res["panfrost"]); if let Ok(dev_id) = driver_str.parse::<u8>() {
if let Some(last_driver) = last_driver {
*res.get_mut(last_driver).unwrap() |= 1 << dev_id;
}
continue;
} else {
let driver_str: Vec<_> = driver_str.split(':').collect();
let mut devices = 0;
if driver_str.len() == 1 {
devices = !0;
} else if let Ok(dev_id) = driver_str[1].parse::<u8>() {
devices |= 1 << dev_id;
}
let driver_str = match driver_str[0] {
"llvmpipe" | "lp" => "swrast",
"freedreno" => "msm",
a => a,
};
res.insert(driver_str.to_owned(), devices);
last_driver = Some(driver_str);
} }
} }
if res.contains_key("panfrost") {
res.insert("panthor".to_owned(), res["panfrost"]);
}
res res
} }

View file

@ -75,6 +75,13 @@ rusticl_args = [
'-Aclippy::type_complexity', '-Aclippy::type_complexity',
] ]
rusticl_drivers_enable = get_option('gallium-rusticl-enable-drivers')
foreach driver : rusticl_drivers_enable
rusticl_args += [
'--cfg', 'rusticl_enable_' + driver,
]
endforeach
if with_platform_x11 if with_platform_x11
rusticl_args += [ rusticl_args += [
'--cfg', 'glx', '--cfg', 'glx',