diff options
| author | raylitebull <287713799+raylitebull@users.noreply.github.com> | 2026-12-01 19:52:57 +0000 |
|---|---|---|
| committer | raylitebull <287713799+raylitebull@users.noreply.github.com> | 2026-12-01 19:52:57 +0000 |
| commit | ef493063f5739f53b2fc317c582725cced918b70 (patch) | |
| tree | c3438627a7f1735c6038e6fe21c440dd068b5b6c | |
| parent | 6bfb5c5153ccc23517daf30aa1071ddb0fadb53c (diff) | |
xcl run: preflight notes a GPU with unified memory and its RAM limituma-dev
An integrated GPU (D3D12_FEATURE_DATA_ARCHITECTURE1::UMA) takes its memory
out of the system RAM the title and XCL also use, so the GPU line's dedicated
VRAM is not what limits the run. The preflight now adds a note saying whether
that memory is cache-coherent and how much RAM the GPU may use
(DXGI_ADAPTER_DESC1::SharedSystemMemory); like every check it also lands in
report.json. WARP reports unified memory too and gets no note.
First step of the experimental unified-memory mode on uma-dev.
Type-checked with cargo check --workspace --all-targets --target
x86_64-pc-windows-gnu; the tests were not run (no Windows machine here).
Assisted-by: Capy (Claude Opus 5.5)
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
| -rw-r--r-- | crates/xcl/src/preflight.rs | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/crates/xcl/src/preflight.rs b/crates/xcl/src/preflight.rs index 230a29bf..c7f8c41d 100644 --- a/crates/xcl/src/preflight.rs +++ b/crates/xcl/src/preflight.rs | |||
| @@ -38,6 +38,11 @@ pub struct Gpu { | |||
| 38 | pub mesh: bool, | 38 | pub mesh: bool, |
| 39 | pub wave_min: u32, | 39 | pub wave_min: u32, |
| 40 | pub wave_max: u32, | 40 | pub wave_max: u32, |
| 41 | /// unified memory (`D3D12_FEATURE_DATA_ARCHITECTURE1::UMA`): an integrated GPU | ||
| 42 | pub uma: bool, | ||
| 43 | pub cache_coherent: bool, | ||
| 44 | /// system RAM the GPU may use (`DXGI_ADAPTER_DESC1::SharedSystemMemory`) | ||
| 45 | pub shared_mb: u64, | ||
| 41 | } | 46 | } |
| 42 | 47 | ||
| 43 | /// Everything the checks look at; `checks` turns it into the list. | 48 | /// Everything the checks look at; `checks` turns it into the list. |
| @@ -77,6 +82,10 @@ pub fn checks(f: &Found) -> Vec<Check> { | |||
| 77 | } else if !wave64 && !wave32 && g.wave_max > 0 { | 82 | } else if !wave64 && !wave32 && g.wave_max > 0 { |
| 78 | v.push(check(Level::Error, format!("waves of {}–{} lanes: neither 64 nor 32, the console's programs cannot run", g.wave_min, g.wave_max), None)); | 83 | v.push(check(Level::Error, format!("waves of {}–{} lanes: neither 64 nor 32, the console's programs cannot run", g.wave_min, g.wave_max), None)); |
| 79 | } | 84 | } |
| 85 | if g.uma && !g.warp { | ||
| 86 | let coherent = if g.cache_coherent { "cache-coherent" } else { "not cache-coherent" }; | ||
| 87 | v.push(check(Level::Note, format!("unified memory ({coherent}): the GPU's memory is the system RAM, up to {} MiB of it – the game, XCL and the GPU share it", g.shared_mb), None)); | ||
| 88 | } | ||
| 80 | } | 89 | } |
| 81 | } | 90 | } |
| 82 | match &f.dxc { | 91 | match &f.dxc { |
| @@ -106,7 +115,7 @@ fn probe_gpu(setting: &str) -> Result<Gpu, String> { | |||
| 106 | unsafe { | 115 | unsafe { |
| 107 | let factory: IDXGIFactory6 = CreateDXGIFactory2(DXGI_CREATE_FACTORY_FLAGS(0)).map_err(|e| format!("DXGI: {e}"))?; | 116 | let factory: IDXGIFactory6 = CreateDXGIFactory2(DXGI_CREATE_FACTORY_FLAGS(0)).map_err(|e| format!("DXGI: {e}"))?; |
| 108 | let sel = Selector::from_env_or(setting); | 117 | let sel = Selector::from_env_or(setting); |
| 109 | let mut found: Option<(ID3D12Device, String)> = None; | 118 | let mut found: Option<(ID3D12Device, String, u64)> = None; |
| 110 | if sel != Selector::Warp { | 119 | if sel != Selector::Warp { |
| 111 | let mut list = adapter::candidates(&factory, &sel); | 120 | let mut list = adapter::candidates(&factory, &sel); |
| 112 | if list.is_empty() { | 121 | if list.is_empty() { |
| @@ -114,18 +123,18 @@ fn probe_gpu(setting: &str) -> Result<Gpu, String> { | |||
| 114 | } | 123 | } |
| 115 | for (a, desc) in list { | 124 | for (a, desc) in list { |
| 116 | if let Ok(dev) = crate::gpu::agility::create_device(&a, D3D_FEATURE_LEVEL_12_0) { | 125 | if let Ok(dev) = crate::gpu::agility::create_device(&a, D3D_FEATURE_LEVEL_12_0) { |
| 117 | found = Some((dev, format!("{} ({} MiB VRAM)", adapter::name(&desc), desc.DedicatedVideoMemory >> 20))); | 126 | found = Some((dev, format!("{} ({} MiB VRAM)", adapter::name(&desc), desc.DedicatedVideoMemory >> 20), (desc.SharedSystemMemory >> 20) as u64)); |
| 118 | break; | 127 | break; |
| 119 | } | 128 | } |
| 120 | } | 129 | } |
| 121 | } | 130 | } |
| 122 | let warp = found.is_none(); | 131 | let warp = found.is_none(); |
| 123 | let (dev, name) = match found { | 132 | let (dev, name, shared_mb) = match found { |
| 124 | Some(x) => x, | 133 | Some(x) => x, |
| 125 | None => { | 134 | None => { |
| 126 | let w: IDXGIAdapter = factory.EnumWarpAdapter().map_err(|e| format!("WARP: {e}"))?; | 135 | let w: IDXGIAdapter = factory.EnumWarpAdapter().map_err(|e| format!("WARP: {e}"))?; |
| 127 | let d = crate::gpu::agility::create_device(&w, D3D_FEATURE_LEVEL_11_0).map_err(|e| format!("WARP: {e}"))?; | 136 | let d = crate::gpu::agility::create_device(&w, D3D_FEATURE_LEVEL_11_0).map_err(|e| format!("WARP: {e}"))?; |
| 128 | (d, "WARP (software renderer)".into()) | 137 | (d, "WARP (software renderer)".into(), 0) |
| 129 | } | 138 | } |
| 130 | }; | 139 | }; |
| 131 | // the highest model asked for that the runtime knows; a lower one comes back if that is all | 140 | // the highest model asked for that the runtime knows; a lower one comes back if that is all |
| @@ -143,8 +152,21 @@ fn probe_gpu(setting: &str) -> Result<Gpu, String> { | |||
| 143 | let mut o7 = D3D12_FEATURE_DATA_D3D12_OPTIONS7::default(); | 152 | let mut o7 = D3D12_FEATURE_DATA_D3D12_OPTIONS7::default(); |
| 144 | let mesh = dev.CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS7, &mut o7 as *mut _ as _, std::mem::size_of_val(&o7) as u32).is_ok() | 153 | let mesh = dev.CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS7, &mut o7 as *mut _ as _, std::mem::size_of_val(&o7) as u32).is_ok() |
| 145 | && o7.MeshShaderTier.0 >= D3D12_MESH_SHADER_TIER_1.0; | 154 | && o7.MeshShaderTier.0 >= D3D12_MESH_SHADER_TIER_1.0; |
| 155 | let mut arch = D3D12_FEATURE_DATA_ARCHITECTURE1::default(); | ||
| 156 | let _ = dev.CheckFeatureSupport(D3D12_FEATURE_ARCHITECTURE1, &mut arch as *mut _ as _, std::mem::size_of_val(&arch) as u32); | ||
| 146 | let no_sm66 = crate::gpu::agility::format_no_sm66_message(&name, crate::gpu::agility::state()); | 157 | let no_sm66 = crate::gpu::agility::format_no_sm66_message(&name, crate::gpu::agility::state()); |
| 147 | Ok(Gpu { name, warp, shader_model, no_sm66, mesh, wave_min: o1.WaveLaneCountMin, wave_max: o1.WaveLaneCountMax }) | 158 | Ok(Gpu { |
| 159 | name, | ||
| 160 | warp, | ||
| 161 | shader_model, | ||
| 162 | no_sm66, | ||
| 163 | mesh, | ||
| 164 | wave_min: o1.WaveLaneCountMin, | ||
| 165 | wave_max: o1.WaveLaneCountMax, | ||
| 166 | uma: arch.UMA.as_bool(), | ||
| 167 | cache_coherent: arch.CacheCoherentUMA.as_bool(), | ||
| 168 | shared_mb, | ||
| 169 | }) | ||
| 148 | } | 170 | } |
| 149 | } | 171 | } |
| 150 | 172 | ||
| @@ -186,7 +208,7 @@ mod tests { | |||
| 186 | use super::*; | 208 | use super::*; |
| 187 | 209 | ||
| 188 | fn gpu() -> Gpu { | 210 | fn gpu() -> Gpu { |
| 189 | Gpu { name: "Radeon RX 9070 (16304 MiB VRAM)".into(), warp: false, shader_model: (6, 6), no_sm66: "x: no SM 6.6".into(), mesh: true, wave_min: 32, wave_max: 64 } | 211 | Gpu { name: "Radeon RX 9070 (16304 MiB VRAM)".into(), warp: false, shader_model: (6, 6), no_sm66: "x: no SM 6.6".into(), mesh: true, wave_min: 32, wave_max: 64, uma: false, cache_coherent: false, shared_mb: 16_000 } |
| 190 | } | 212 | } |
| 191 | 213 | ||
| 192 | fn found(gpu: Gpu) -> Found { | 214 | fn found(gpu: Gpu) -> Found { |
| @@ -233,6 +255,16 @@ mod tests { | |||
| 233 | } | 255 | } |
| 234 | 256 | ||
| 235 | #[test] | 257 | #[test] |
| 258 | fn unified_memory_is_a_note() { | ||
| 259 | let c = checks(&found(Gpu { uma: true, cache_coherent: true, shared_mb: 15_948, ..gpu() })); | ||
| 260 | assert_eq!(c[1].level, Level::Note); | ||
| 261 | assert!(c[1].what.contains("unified memory (cache-coherent)") && c[1].what.contains("15948 MiB"), "{:?}", c[1]); | ||
| 262 | assert!(checks(&found(Gpu { uma: true, ..gpu() }))[1].what.contains("not cache-coherent")); | ||
| 263 | // WARP reports unified memory too, but it is no GPU | ||
| 264 | assert_eq!(levels(&found(Gpu { uma: true, warp: true, ..gpu() })), [Level::Warning, Level::Ok]); | ||
| 265 | } | ||
| 266 | |||
| 267 | #[test] | ||
| 236 | fn an_old_dxc_is_a_note_with_a_fix() { | 268 | fn an_old_dxc_is_a_note_with_a_fix() { |
| 237 | let c = checks(&Found { dxc_toolchain: dxc(1, 7), ..found(gpu()) }); | 269 | let c = checks(&Found { dxc_toolchain: dxc(1, 7), ..found(gpu()) }); |
| 238 | assert_eq!(c.iter().map(|c| c.level).collect::<Vec<_>>(), [Level::Ok, Level::Ok, Level::Note]); | 270 | assert_eq!(c.iter().map(|c| c.level).collect::<Vec<_>>(), [Level::Ok, Level::Ok, Level::Note]); |