mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 04:48:08 +02:00
rusticl/device: allow overwriting the device_type via env
Signed-off-by: Karol Herbst <kherbst@redhat.com> Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15439>
This commit is contained in:
parent
90f0f91ce2
commit
82b477751e
1 changed files with 19 additions and 0 deletions
|
|
@ -289,6 +289,21 @@ impl Device {
|
|||
!self.long_supported()
|
||||
}
|
||||
|
||||
fn parse_env_device_type() -> Option<cl_device_type> {
|
||||
let mut val = env::var("RUSTICL_DEVICE_TYPE").ok()?;
|
||||
val.make_ascii_lowercase();
|
||||
Some(
|
||||
match &*val {
|
||||
"accelerator" => CL_DEVICE_TYPE_ACCELERATOR,
|
||||
"cpu" => CL_DEVICE_TYPE_CPU,
|
||||
"custom" => CL_DEVICE_TYPE_CUSTOM,
|
||||
"gpu" => CL_DEVICE_TYPE_GPU,
|
||||
_ => return None,
|
||||
}
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
|
||||
fn parse_env_version() -> Option<CLVersion> {
|
||||
let val = env::var("RUSTICL_CL_VERSION").ok()?;
|
||||
let (major, minor) = val.split_once('.')?;
|
||||
|
|
@ -458,6 +473,10 @@ impl Device {
|
|||
}
|
||||
|
||||
pub fn device_type(&self, internal: bool) -> cl_device_type {
|
||||
if let Some(env) = Self::parse_env_device_type() {
|
||||
return env;
|
||||
}
|
||||
|
||||
if self.custom {
|
||||
return CL_DEVICE_TYPE_CUSTOM as cl_device_type;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue