A GPU without VK_EXT_external_memory_host runs the game on shadow storage instead of being skipped

The extension was in vk_device.c k_required_ext, so pick_device skipped every GPU without it ("gpu 0 skipped: missing
extension VK_EXT_external_memory_host") and the game exited: Qualcomm Adreno's Windows driver (issue #161), some older
or mobile drivers, and RenderDoc, which hides it. It is now enabled when present (VkCtx.has_external_memory_host); without
it vk_memory.c mirror_mode turns shadow storage on, the path Wine already takes, so import_pool gives every CPU-visible
pool a host-visible copy instead of an import. vk_mem_class_log runs once the device's extensions are known.
TOTK_VK_NO_HOST_IMPORT=1 takes that path on any GPU, for testing it. Docs no longer list the extension as required.

Iris Xe with a test layer that hides the extension: dev skips the GPU and exits (70); this change plays the sky-island
save (40 s, 39.9 fps, shadow storage logged). With the extension present nothing changes.
This commit is contained in:
Ruan Shannon committed 2026-11-22 05:01:27 -08:00
1 parent afae80c908
commit f877aae10e
9 files changed
+35 -15

No files matched your search

+11 -3
View File
@@ -1867,7 +1867,7 @@ static PlatMutex mirror_stat_lock = PLAT_MUTEX_INIT;
static volatile int64_t m_live_n, m_live_bytes, m_refused_n[MR_N], m_refused_bytes[MR_N];
static volatile int64_t m_flush_calls, m_flush_bytes, v_pages, v_skipped, v_mismatch;
static void mirror_mode(int discrete) {
static void mirror_mode(int discrete, int host_import) {
const char *e = cfg_value("TOTK_MEMORY");
int mode = discrete ? 1 : 0; // 0 import, 1 mirror, 2 verify
const char *why = discrete ? "auto, discrete gpu" : "auto, uma";
@@ -1902,6 +1902,14 @@ static void mirror_mode(int discrete) {
#else
shadow_on = !sh || !*sh || strcmp(sh, "0");
#endif
// Without VK_EXT_external_memory_host (Qualcomm Adreno's Windows driver, some mobile and older drivers, or
// TOTK_VK_NO_HOST_IMPORT=1) guest memory cannot be imported: every CPU-visible pool gets shadow storage, the path
// Wine already takes (import_pool -> shadow_pool), whatever TOTK_SHADOW says.
if (!host_import) {
if (!shadow_on) rt_log("mem: no host import (VK_EXT_external_memory_host): shadow storage%s",
sh && *sh ? ", TOTK_SHADOW=0 overridden" : "");
shadow_on = 1;
}
defer_on = shadow_on && cfg_bool("TOTK_SYNC_AHEAD") && strcmp(cfg_value("TOTK_SYNC_AHEAD"), "check") &&
cfg_bool("TOTK_SHADOW_DEFER"); // check: the wait stays exact, nothing is deferred
if (defer_on) rt_log("mem: TOTK_SHADOW_DEFER: shadow updates that wait for a reader are queued for the GPU instead");
@@ -2931,7 +2939,7 @@ static void vram_log(uint64_t frame) {
// Device class: INTEGRATED -> uma; a discrete GPU with a DEVICE_LOCAL heap of 1 GiB or more beside a
// heap that is not device-local (host memory) -> discrete; otherwise uma (import everywhere). Sets the mirror mode.
void vk_mem_class_log(const VkPhysicalDeviceProperties *p, const VkPhysicalDeviceMemoryProperties *m) {
void vk_mem_class_log(const VkPhysicalDeviceProperties *p, const VkPhysicalDeviceMemoryProperties *m, int host_import) {
int big_local = -1, host_heap = -1;
for (uint32_t h = 0; h < m->memoryHeapCount; h++) {
if (m->memoryHeaps[h].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) {
@@ -2973,7 +2981,7 @@ void vk_mem_class_log(const VkPhysicalDeviceProperties *p, const VkPhysicalDevic
if (host_backed == HB_UMA)
rt_log("mem: device memory against system memory: commit and physical memory (uma), reserve %llu MiB "
"(TOTK_MEM_RESERVE_MIB)", (unsigned long long)(room_reserve >> 20));
mirror_mode(discrete);
mirror_mode(discrete, host_import);
}
// ---------------------------------------------------------------- upload batches and deferred destruction