mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 05:18:08 +02:00
rusticl/device: add DeviceCaps and move timestamp stuff into it
We do query caps quite a lot and this struct should be used to cache results and to make it easier to express more complex dependencies between features (e.g. images being supported or not). Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29205>
This commit is contained in:
parent
e3e5f8e6db
commit
e02b4e0d44
3 changed files with 24 additions and 13 deletions
|
|
@ -258,7 +258,9 @@ impl CLInfo<cl_device_info> for cl_device_id {
|
|||
} else {
|
||||
"FULL_PROFILE"
|
||||
}),
|
||||
CL_DEVICE_PROFILING_TIMER_RESOLUTION => cl_prop::<usize>(dev.timer_resolution()),
|
||||
CL_DEVICE_PROFILING_TIMER_RESOLUTION => {
|
||||
cl_prop::<usize>(dev.caps.timer_resolution as usize)
|
||||
}
|
||||
CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE => cl_prop::<cl_uint>(0),
|
||||
CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE => cl_prop::<cl_uint>(0),
|
||||
CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES => cl_prop::<cl_command_queue_properties>(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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,16 +39,33 @@ pub struct Device {
|
|||
pub clc_versions: Vec<cl_name_version>,
|
||||
pub custom: bool,
|
||||
pub embedded: bool,
|
||||
pub has_timestamp: bool, // Cached to keep API fast
|
||||
pub extension_string: String,
|
||||
pub extensions: Vec<cl_name_version>,
|
||||
pub spirv_extensions: Vec<CString>,
|
||||
pub clc_features: Vec<cl_name_version>,
|
||||
pub formats: HashMap<cl_image_format, HashMap<cl_mem_object_type, cl_mem_flags>>,
|
||||
pub lib_clc: NirShader,
|
||||
pub caps: DeviceCaps,
|
||||
helper_ctx: Mutex<PipeContext>,
|
||||
}
|
||||
|
||||
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<F>(&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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue