mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:45:54 +01:00
[PR #1259] d3d12: on Intel the GPU reads a fresh host import before it is handed out (RT-INTEL-IMPORT-SETTLE) #1291
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#1291
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/1259
Author: @MalexAson
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:fix/intel-host-import-settle📝 Commits (1)
2702cd3d3d12: on Intel the GPU reads a fresh host import before it is handed out (RT-INTEL-IMPORT-SETTLE)📊 Changes
3 files changed (+154 additions, -3 deletions)
View changed files
📝
docs/d3d12_vulkan.md(+1 -1)📝
runtime/shims/d3d12_vulkan_device.cpp(+75 -2)📝
runtime/test/d3d12_existing_heap_test.cpp(+78 -0)📄 Description
Claimed in the coordination issue as: RT-INTEL-IMPORT-SETTLE
What and why
d3d12_existing_heapfails with the layer on an Intel Iris Xe:[rt] d3d12: ExecuteCommandLists failed: unsupported; nothing was submitted, thenvulkan slot-133 buffer line 219: SUCCEEDED(queue->Signal(fence.p, 1)), three times. It passes on an RTX 4060 in the same machine. I reported it as a finding in https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7142086637 and guessed wrong there: the copy out of the title-placed buffer is not at fault.Which check says
unsupported. None of the replay checks.vkQueueSubmitreturnsVK_ERROR_DEVICE_LOSTfor the first copy,VulkanQueue::submitmarks the device lost, andexecute_nowreports a batch that was not submitted asunsupported. The second and third failure areexecute_nowrefusing at its entry because the device is lost.What loses the device. Not the title-placed buffer. With
open_casesskipped the test passes on the Iris Xe; with only its write-combined 64 KiB case or only its 2 MiB case it fails; with all cases but without theVirtualFreeat its end it passes.open_casesopens existing heaps, releases them and frees their pages at once. The heap frees its import inRelease, as it should, but Intel's driver is not done with the pages yet.A raw Vulkan program without the layer (
vkAllocateMemorywith a host pointer,vkFreeMemory,VirtualFree, then a copy between two ordinary buffers), Iris Xe, Intel 32.0.101.7092, runs that lost the device:vkDeviceWaitIdlebefore the freevkQueueSubmitwithout command buffers andvkQueueWaitIdlebefore the freeThe delay counts from
vkAllocateMemory, not fromvkFreeMemory: 100 µs between the import andvkFreeMemorywith the pages freed right after is 0 of 20 as well. No buffer has to be bound to the import for this. The memory type does not matter (type 1, flags 0x7, and type 2, flags 0xf, both lose it), nor doesVK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BITor writing to the pages before the import. The RTX 4060 (NVIDIA 621.40) lost its device in 0 of 20 runs at 64 KiB, 1 MiB and 64 MiB. On the Iris Xe's own D3D12 driver,OpenExistingHeapFromAddress,Release,VirtualFreeand a submitted copy keep the device in 10 of 10 runs at 1 MiB and at 64 MiB, so a title may do this.The first copy out of a fresh import takes 0.1 to 0.5 ms for 64 KiB and 1.3 to 2.5 ms for 64 MiB, on both drivers, so that is where a driver takes hold of the pages, and afterwards freeing them loses nothing.
The change.
DeviceState::settle_host_import: on an Intel GPU,OpenExistingHeapFromAddressand a title-placed buffer (device slot 133,create_host_buffer) copy four bytes out of the new import into a scratch buffer on the device's queue and wait for it, before the heap or buffer is handed out. It goes through the staging queue, asstaged_copydoes forWriteToSubresource. In the test it takes 0.3 to 0.8 ms per import on the Iris Xe. Other vendors run the same code as before.d3d12_existing_heap_testgainscheck_pages_freed_at_once: three existing heaps and three placed buffers (64 KiB, 1 MiB, 16 MiB), each released with its pages freed at once, then a copy andGetDeviceRemovedReason.docs/d3d12_vulkan.mdhas the measurements in the "Heaps and placed resources" row.Two things for a maintainer to decide.
VK_EXT_external_memory_host(the pages only have to stay valid while theVkDeviceMemorylives). I did not find a way to ask the driver whether it is done, so the read is what I measured to be enough, not something the specification promises.Not covered: Intel Arc and Intel on Linux get the read without having been measured, AMD does not get it and was not measured. The 14 GiB whole-region import of RT-TITLE-HOST-REGION is another code path and is not touched.
Overlap: #644, #1100, #1190 and #1192 change the same two source files. This merges cleanly with the current head of each (
git merge-tree), and it does not depend on any of them. #1192 reports thatd3d12_existing_heapfails on cleanmainon an Intel UHD at the first aligned copy; that is probably this.Tested
With MSVC 19.50 (Build Tools 2026), RelWithDebInfo, Windows 11 build 26100.6584, each on both GPUs through
LEONIDA_VK_DEVICE. The numbers without the change and the raw-program numbers above were taken onmain58be9cdf8, the numbers with the change onmain66d4f5aa3:d3d12_existing_heapwithout the change: fails on the Iris Xe in every run (the three lines above), passes on the RTX 4060. With it: 20 of 20 runs pass on each GPU.check_pages_freed_at_oncerun alone, through a local switch that is not in this pull request: without the read it fails in 10 of 10 runs on the Iris Xe, at itsqueue->Signal; with it in 0 of 10; on the RTX 4060 it passes 10 of 10.ctest -R "d3d12_existing_heap|d3d12_descriptor|d3d12_console_descriptor_heap|xmem"(xmem,d3d12_existing_heap,d3d12_xmem_placed,d3d12_descriptor,d3d12_console_descriptor_heap): 5 of 5 pass on both GPUs.python -I scripts/check_no_game_data.pyon the three changed files, andgit diff --check.ctest(only these five targets were built),LEONIDA_VK_VALIDATION=1(no validation layer on this PC), an AMD GPU, an Intel Arc, Linux or Wine.GPUs tested: Intel Iris Xe (Raptor Lake-P, 8086:a7a0), Intel 32.0.101.7092, Windows 11 build 26100.6584; NVIDIA GeForce RTX 4060 Laptop GPU, NVIDIA 621.40, Windows 11 build 26100.6584
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (not applicable: no translator change)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.