mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-06 00:08:52 +00:00
Setup wizard: show the VRAM of AMD cards on Windows from the engine's list when the host probe reports 0 (#3727, PR #3798 by chicco83)
This commit is contained in:
1 parent
1d20d3e2b0
commit
90a7aeea51
1 file changed
+13
-2
@@ -8,9 +8,20 @@ export function OnboardingMemory({ hardware, native }: {
|
||||
hardware: Hardware | null;
|
||||
native: NativeState['hardware'] | undefined;
|
||||
}) {
|
||||
const gpus = hardware ? hardware.gpus.filter(gpu => gpu.backend !== 'cpu').map(gpu => ({ id: gpu.id ?? String(gpu.index), name: gpu.name, memory: gpu.vramGb, shared: gpu.unified })) : native?.gpus.map(gpu => ({ id: String(gpu.index), name: gpu.name, memory: gpu.vram_gb, shared: false })) ?? [];
|
||||
// The Windows host probe (Win32_VideoController) cannot read the VRAM of AMD cards and reports 0 for them; the engine's own list has
|
||||
// the real size. For a dedicated card the host reports as 0, take the engine's figure for the card of the same name, or for the
|
||||
// card in the same position when both lists have the same length. A card the engine does not list stays at 0.
|
||||
const nativeGpus = native?.gpus ?? [];
|
||||
const hostGpus = hardware ? hardware.gpus.filter(gpu => gpu.backend !== 'cpu') : [];
|
||||
const engineVram = (name: string, position: number) => {
|
||||
const norm = (value: string) => value.toLowerCase().replace(/[^a-z0-9]/g, '');
|
||||
const byName = nativeGpus.find(g => norm(g.name).includes(norm(name)) || norm(name).includes(norm(g.name)));
|
||||
return (byName ?? (nativeGpus.length === hostGpus.length ? nativeGpus[position] : undefined))?.vram_gb || 0;
|
||||
};
|
||||
const gpus = hardware ? hostGpus.map((gpu, position) => ({ id: gpu.id ?? String(gpu.index), name: gpu.name, memory: gpu.unified || gpu.vramGb > 0 ? gpu.vramGb : engineVram(gpu.name, position), shared: gpu.unified })) : nativeGpus.map(gpu => ({ id: String(gpu.index), name: gpu.name, memory: gpu.vram_gb, shared: false }));
|
||||
const dedicatedCount = gpus.filter(gpu => !gpu.shared).length;
|
||||
const memory = hardware ? memoryInventory(hardware) : native ? { ram: native.ram_gb, vram: native.gpus.reduce((sum, gpu) => sum + Math.max(0, gpu.vram_gb || 0), 0), total: 0, shared: false } : null;
|
||||
const base = hardware ? memoryInventory(hardware) : null;
|
||||
const memory = base ? (base.shared ? base : { ...base, vram: gpus.reduce((sum, gpu) => sum + (gpu.shared ? 0 : Math.max(0, gpu.memory || 0)), 0) }) : native ? { ram: native.ram_gb, vram: native.gpus.reduce((sum, gpu) => sum + Math.max(0, gpu.vram_gb || 0), 0), total: 0, shared: false } : null;
|
||||
if (!memory)
|
||||
return <div className="onboard-hardware" role="group" aria-label={tr("Computer memory")}><div className="onboard-memory-intro"><Icon name="memory" size={18}/><span>{tr("Reading memory\u2026")}</span></div></div>;
|
||||
const total = memory.ram + memory.vram;
|
||||
|
||||
Reference in new issue
Block a user