mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:00:52 +01:00
[PR #2126] d3d12: decline file-backed/multi-VMA host imports under Wine and deduplicate import memory types (RT-WINE-HOST-IMPORT-POLICY) #2131
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#2131
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/2126
Author: @djrolfes
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:djrolfes/rt-wine-mapped-host-import📝 Commits (1)
1431ac4d3d12: decline file-backed/multi-VMA host imports under Wine and deduplicate import memory types📊 Changes
5 files changed (+339 additions, -73 deletions)
View changed files
📝
runtime/CMakeLists.txt(+4 -0)📝
runtime/shims/d3d12_vulkan_device.cpp(+105 -73)➕
runtime/src/host_import_policy.h(+73 -0)📝
runtime/test/d3d12_existing_heap_test.cpp(+44 -0)➕
runtime/test/host_import_policy_test.cpp(+113 -0)📄 Description
Claimed in the coordination issue as: RT-WINE-HOST-IMPORT-POLICY (#1608)
What and why
Under Wine on Linux,
nvidia.korejects long-term pinning (pin_user_pages/FOLL_LONGTERM) of file-backedMAP_SHAREDviews (such as the sparse temp files created underLEONIDA_XMEM_BACKING_DIR) with kernelCannot map memory with base addr ...errors and also rejects host-pointer imports spanning multiple VMAs. Asd3d12_vulkan_device.cppnotes, bursts of those kernel rejections on NVIDIA 620.73 under Wine coincide with spuriousVK_ERROR_OUT_OF_HOST_MEMORY(-1) responses on concurrent normalvkAllocateMemorycalls, causingE_OUTOFMEMORY(0x8007000e) resource-creation failures even with gigabytes of VRAM and RAM free.This change fixes four related issues in the host-import path without altering native Windows host-import eligibility or anonymous pagefile section imports (the four runtime-path invariants below — post-
holdTOCTOU re-check,memory_mutex()around importvkAllocateMemory, single-pass memory-type deduplication, and stopping early onVK_ERROR_INVALID_EXTERNAL_HANDLE— apply on native Windows as well as Wine):runtime/src/host_import_policy.h(HostImportRangeCheckandhost_import_memory_types) and CPU unit testruntime/test/host_import_policy_test.cpp:ntdll!wine_get_version), declinesMEM_MAPPEDregions backed by a named file (K32GetMappedFileNameW > 0) and ranges spanning multipleAllocationBasevalues before calling Vulkan, while keeping anonymousVirtualAlloc(MEM_PRIVATE) and anonymous pagefile sections (CreateFileMappingW(INVALID_HANDLE_VALUE, ...)) importable.HOST_VISIBLE | HOST_COHERENT) and fallback passes so a failing import never probes the same memory type twice.host_range_importableafterleonida::kernel_writes::holdincreate_host_bufferandimport_console_heap(closing the TOCTOU window between the writability check and the pin) and stops probing further memory types onVK_ERROR_INVALID_EXTERNAL_HANDLE.DeviceState::memory_mutex()consistently aroundvkAllocateMemoryinimport_console_heap,OpenExistingHeapFromAddress, and theImageMemoryblock allocator (matchingDeviceState::memory_mutex()'s documented invariant).runtime/test/d3d12_existing_heap_test.cppverifying shadow fallback without host import under Wine.Opened as a draft because prior pull requests are currently open (one-open-PR limit).
Tested
python3 -I scripts/check_no_game_data.pyon all 5 touched/added files: passed.runtime/build/native, Linux / Clang 23.1.5): 100/100 passed (98 passed, 2 conditional skips:shader_library_corpus,vk_sync_validation), including newhost_import_policy.clang-cl+xwin, Wine, network-isolated, no retail files):host_import_policy_test: passedd3d12_console_descriptor_heap_test: passedd3d12_xmem_placed_test: passedd3d12_existing_heap_test(including new sparse disk-file-backed section case): passed, 0 kernelCannot map memoryerrors.--first-run-uiA/B check (no input, 300 s bounded, read-only package/shaders/BCPack predictor, network-isolated, counts/timings only):main(490f5b9ec): exit 126 at 28.42 s (slot 133 depth texture refused,hr=0x8007000e), 16 kernelCannot map memoryerrors across 7MEM_MAPPEDaddresses, 2vkAllocateMemory failed (-1), 347PresentX ok.f5bc25cdc+ fix): ran full 300.88 s time limit (exit 124), 0 kernelCannot map memoryerrors, 0vkAllocateMemory failed (-1), 0 depth-texture refusals, 7,990PresentX ok, 200MEM_PRIVATEslot-133 imports succeeded. Rebased cleanly onto1fe5072afand re-verifiedhost_import_policy_test+d3d12_existing_heap_test.GPUs tested: NVIDIA GeForce RTX 3070 Ti (8 GB), driver 620.73.04, Linux (Arch/Omarchy) under Wine.
AI-assisted: yes.
Checklist
main(1fe5072af) and merges cleanly.docs/design.md, with how it was confirmed. (n/a: runtime-only change)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.