From 1ed1dcb9db6aa02da5a63bd431bb68efda252c6b Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Tue, 24 Mar 2026 03:07:09 +0100 Subject: [PATCH] rusticl/device: Fix reporting of global memory on mixed memory devices AMD APUs are hitting this case where they have very small discrete VRAM, but a lot of staging memory, which can be used additionally. Fixes: 7487ac20463 ("rusticl/device: support query_memory_info to retrieve available memory") (cherry picked from commit 58d45725c7cca54c02079566e0f0bb59b16a1e5d) Part-of: --- .pick_status.json | 2 +- src/gallium/frontends/rusticl/core/device.rs | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 126d2b1d6e8..a77d8b54a30 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -964,7 +964,7 @@ "description": "rusticl/device: Fix reporting of global memory on mixed memory devices", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "7487ac204634a421d7dd5a076f9ac8f512571f5b", "notes": null diff --git a/src/gallium/frontends/rusticl/core/device.rs b/src/gallium/frontends/rusticl/core/device.rs index e5604069b3b..688a430d402 100644 --- a/src/gallium/frontends/rusticl/core/device.rs +++ b/src/gallium/frontends/rusticl/core/device.rs @@ -971,11 +971,19 @@ impl DeviceBase { pub fn global_mem_size(&self) -> cl_ulong { 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() + let device_memory: cl_ulong = memory_info.total_device_memory.into(); + let staging_memory: cl_ulong = memory_info.total_staging_memory.into(); + + // In case some driver doesn't set uma correctly. + let memory = if device_memory == 0 { + staging_memory + } else if self.unified_memory() { + // For UMA devices we expose both. + staging_memory + device_memory } else { - memory_info.total_staging_memory.into() + device_memory }; + memory * 1024 } else { self.screen.compute_caps().max_global_size