mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 15:58:05 +02:00
rusticl/device: support query_memory_info to retrieve available memory
Some drivers implement query_memory_info, but not the MAX_GLOBAL_SIZE compute cap. Long term we should drop the compute cap anyway. Signed-off-by: Karol Herbst <kherbst@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28122>
This commit is contained in:
parent
2df640c4f6
commit
7487ac2046
2 changed files with 19 additions and 2 deletions
|
|
@ -785,8 +785,17 @@ impl Device {
|
|||
}
|
||||
|
||||
pub fn global_mem_size(&self) -> cl_ulong {
|
||||
self.screen
|
||||
.compute_param(pipe_compute_cap::PIPE_COMPUTE_CAP_MAX_GLOBAL_SIZE)
|
||||
if let Some(memory_info) = self.screen().query_memory_info() {
|
||||
let memory: cl_ulong = if memory_info.total_device_memory != 0 {
|
||||
memory_info.total_device_memory.into()
|
||||
} else {
|
||||
memory_info.total_staging_memory.into()
|
||||
};
|
||||
memory * 1024
|
||||
} else {
|
||||
self.screen
|
||||
.compute_param(pipe_compute_cap::PIPE_COMPUTE_CAP_MAX_GLOBAL_SIZE)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn image_2d_size(&self) -> usize {
|
||||
|
|
|
|||
|
|
@ -449,6 +449,14 @@ impl PipeScreen {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn query_memory_info(&self) -> Option<pipe_memory_info> {
|
||||
let mut info = pipe_memory_info::default();
|
||||
unsafe {
|
||||
self.screen().query_memory_info?(self.screen.as_ptr(), &mut info);
|
||||
}
|
||||
Some(info)
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for PipeScreen {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue