diff --git a/src/gallium/frontends/rusticl/api/device.rs b/src/gallium/frontends/rusticl/api/device.rs index 3bae01361a7..3831949febc 100644 --- a/src/gallium/frontends/rusticl/api/device.rs +++ b/src/gallium/frontends/rusticl/api/device.rs @@ -258,7 +258,9 @@ impl CLInfo for cl_device_id { } else { "FULL_PROFILE" }), - CL_DEVICE_PROFILING_TIMER_RESOLUTION => cl_prop::(dev.timer_resolution()), + CL_DEVICE_PROFILING_TIMER_RESOLUTION => { + cl_prop::(dev.caps.timer_resolution as usize) + } CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE => cl_prop::(0), CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE => cl_prop::(0), CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES => cl_prop::(0), @@ -407,7 +409,7 @@ fn get_host_timer(device_id: cl_device_id, host_timestamp: *mut cl_ulong) -> CLR let device = Device::ref_from_raw(device_id)?; - if !device.has_timestamp { + if !device.caps.has_timestamp { // CL_INVALID_OPERATION if the platform associated with device does not support device and host timer synchronization return Err(CL_INVALID_OPERATION); } diff --git a/src/gallium/frontends/rusticl/api/queue.rs b/src/gallium/frontends/rusticl/api/queue.rs index 957faffaa55..666fa6087cd 100644 --- a/src/gallium/frontends/rusticl/api/queue.rs +++ b/src/gallium/frontends/rusticl/api/queue.rs @@ -61,7 +61,7 @@ fn supported_command_queue_properties( return false; } - if properties & profiling != 0 && !dev.has_timestamp { + if properties & profiling != 0 && !dev.caps.has_timestamp { return false; } diff --git a/src/gallium/frontends/rusticl/core/device.rs b/src/gallium/frontends/rusticl/core/device.rs index 0e5c0601171..329629596b8 100644 --- a/src/gallium/frontends/rusticl/core/device.rs +++ b/src/gallium/frontends/rusticl/core/device.rs @@ -39,16 +39,33 @@ pub struct Device { pub clc_versions: Vec, pub custom: bool, pub embedded: bool, - pub has_timestamp: bool, // Cached to keep API fast pub extension_string: String, pub extensions: Vec, pub spirv_extensions: Vec, pub clc_features: Vec, pub formats: HashMap>, pub lib_clc: NirShader, + pub caps: DeviceCaps, helper_ctx: Mutex, } +pub struct DeviceCaps { + pub has_timestamp: bool, + pub timer_resolution: u32, +} + +impl DeviceCaps { + fn new(screen: &PipeScreen) -> Self { + let cap_timestamp = screen.param(pipe_cap::PIPE_CAP_QUERY_TIMESTAMP) != 0; + let timer_resolution = screen.param(pipe_cap::PIPE_CAP_TIMER_RESOLUTION) as u32; + + Self { + has_timestamp: cap_timestamp && timer_resolution > 0, + timer_resolution: timer_resolution, + } + } +} + pub trait HelperContextWrapper { #[must_use] fn exec(&self, func: F) -> PipeFence @@ -230,6 +247,7 @@ impl Device { } let mut d = Self { + caps: DeviceCaps::new(&screen), base: CLObjectBase::new(RusticlTypes::Device), helper_ctx: Mutex::new(helper_ctx), screen: screen, @@ -238,7 +256,6 @@ impl Device { clc_versions: Vec::new(), custom: false, embedded: false, - has_timestamp: false, extension_string: String::from(""), extensions: Vec::new(), spirv_extensions: Vec::new(), @@ -255,10 +272,6 @@ impl Device { // check if we have to report it as a custom device d.custom = d.check_custom(); - let cap_timestamp = d.screen.param(pipe_cap::PIPE_CAP_QUERY_TIMESTAMP); - let cap_timestamp_res = d.timer_resolution(); - d.has_timestamp = cap_timestamp != 0 && cap_timestamp_res > 0; - // query supported extensions d.fill_extensions(); @@ -1003,10 +1016,6 @@ impl Device { self.screen.param(pipe_cap::PIPE_CAP_SYSTEM_SVM) == 1 } - pub fn timer_resolution(&self) -> usize { - self.screen.param(pipe_cap::PIPE_CAP_TIMER_RESOLUTION) as usize - } - pub fn unified_memory(&self) -> bool { self.screen.param(pipe_cap::PIPE_CAP_UMA) == 1 }