Repository navigation
d3d12: LEONIDA_HOST_IMAGE_COPY switch; auto leaves host image copies off on NVIDIA - #1851
Conversation
The layer enables VK_EXT_host_image_copy for WriteToSubresource and ReadFromSubresource whenever the device has the extension and its hostImageCopy feature. On an RTX 4070 SUPER (Windows 11) a real boot lost the device with WRITE_INVALID in 7 of 7 runs that used host image copies and in 0 of 2 that did not. The mechanism is not known yet. LEONIDA_HOST_IMAGE_COPY chooses: 0 never, 1 whenever available, auto (the default, also for unset or unrecognized text) as 1 except on NVIDIA (vendorID 0x10DE), where it is off. Off, the extension is neither enabled nor chained, so no image gets host-transfer usage and every CPU texture copy takes the existing staging submit, as on a device without it. The choice is a pure function (src/host_image_copy_policy.h) with a unit test of its table, and device creation logs one line with the choice and the reason in place of the old "no VK_EXT_host_image_copy" line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf
|
Please land #1827 before enabling the NVIDIA default in this PR. I reproduced the dependency on an RTX 4090 (Windows 11, NVIDIA 616.64) using the production
Exact sources were #1851 The R8 fixture was AI-assisted verification with OpenAI Codex. |
MoonEyes
left a comment
There was a problem hiding this comment.
One more NVIDIA configuration: desktop RTX 4060 (Ada), driver 610.88, Windows 11, MSVC 19.44 RelWithDebInfo, head 59c1586.
host_image_copy_policy: passes.d3d12_texture_memoryandd3d12_texture1d(both build the device throughcreate_vulkan_device_standalone, so they read the switch), run three times:
LEONIDA_HOST_IMAGE_COPY |
logged line | the 2 tests |
|---|---|---|
| unset | host image copy: off (auto: NVIDIA); CPU texture copies use a staging submit |
2/2 passed |
0 |
host image copy: off (LEONIDA_HOST_IMAGE_COPY=0); CPU texture copies use a staging submit |
2/2 passed |
1 |
host image copy: on (LEONIDA_HOST_IMAGE_COPY=1) |
2/2 passed |
These two only check that the switch is read and the device comes up; they do no CPU texture copies. d3d12_subresource_copy builds its own devices with host_image_copy set per path, so it ignores the switch: in all three runs its host-image-copy and forced-retry paths reported 0 mismatches against the host and Microsoft's recorded answers (109 steps each). That says host copies are correct in this synthetic test on this card, not that the switch's staging path was exercised. None of this covers the BC7/R8 cases from the 4090 comment here (#1827).
A driver fact that may help with the open mechanism: on this card and driver, vulkaninfo reports identicalMemoryTypeRequirements = false (VkPhysicalDeviceVulkan14Properties, promoted from VkPhysicalDeviceHostImageCopyPropertiesEXT), with hostImageCopy = true and 28 copy src/dst layouts. So adding VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT may change an image's memory requirements on NVIDIA. The layer adds that usage (d3d12_vulkan_device.cpp 6196); it compares memoryTypeBits with and without that usage for staged title images (6237-6258) and retries without it when no type is allowed (6332), but not for ordinary textures. That fits your note that the switch also changes the images' memory type; it is a lead, not a cause.
The in-game replication on a 4070 Laptop / 621.40 is in #1608 (made with a local info.host_image_copy = false, not this switch). #1810 also accepts off (here off falls to auto, so stays on outside NVIDIA) and makes the test harness (vk_test_device.h) honour =0; this PR covers =0 in the layer only.
AI-assisted: yes (Claude Code ran the build and the tests; a separate agent checked this text against the logs and the code; I read both).
|
@ecox982745 thank you, that's an important catch, and the table makes it unambiguous. Without host copies, title images take neither path before #1827, so AI-assisted (Claude Code, Claude Opus 5.5). |
madvillain91
left a comment
There was a problem hiding this comment.
Independent NVIDIA Ampere data point on Windows 11 26H2 (26300.9711) at 59c1586 against main 384abe5 (PR base 98c2f77), using VS 2022 Build Tools (MSVC 19.44.35230.0, RelWithDebInfo, Ninja), Vulkan SDK 1.4.363.0, and NVIDIA GeForce RTX 3070 Ti (driver 617.14, Vulkan 1.4.351).
vulkaninforeportshostImageCopy = trueandidenticalMemoryTypeRequirements = falseon Ampere / 617.14 as well.host_image_copy_policy_test: passed (all cases passed).d3d12_texture_memory_test&d3d12_texture1d_test(both viacreate_vulkan_device_standalone):- unset:
[rt] d3d12: host image copy: off (auto: NVIDIA); CPU texture copies use a staging submit(2/2 passed) LEONIDA_HOST_IMAGE_COPY=0:[rt] d3d12: host image copy: off (LEONIDA_HOST_IMAGE_COPY=0); CPU texture copies use a staging submit(2/2 passed)LEONIDA_HOST_IMAGE_COPY=1:[rt] d3d12: host image copy: on (LEONIDA_HOST_IMAGE_COPY=1)(2/2 passed)
- unset:
d3d12_subresource_copy_test: passed.
Also independently verified prerequisite #1827 on this same RTX 3070 Ti (d3d12_existing_heap_test staged host_image_copy=false paths + d3d12_subresource_copy_test + d3d12_m2_textured_test, all 0 VUIDs under LEONIDA_VK_VALIDATION=1). Not checked: retail boot. LGTM (pending #1827 landing first as noted).
AI-assisted verification.
|
Note: #1810 by abnalstlll-byte (opened earlier) adds AI-assisted (Claude Code, Claude Opus 5.5). |
|
#1827 has landed on main (ea6d535, via #1192 at 3d4f661), so the dependency is met: with AI-assisted (Claude Code, Claude Opus 5.5). |
|
Data point, not a decision: with #1893 (fixes the D32S8 → D32 depth copy that wrote past the end of the D32 image) and host image copy on (default), I no longer get crash A on my RTX 4070 Laptop 8 GB, driver 621.40.
So turning host image copy off may no longer be needed against crash A. That is 2 runs on one machine. Could someone with a 12 GB+ card (and ideally one who reproduced A with host copy on) run #1893 with host image copy on before we decide on this PR? AI-assisted. |
|
@OreoFR that's a much better explanation than mine: a mismatched-format depth copy writing past the D32 image fits everything I saw (a driver routine, no translated store, the fault just past an image). It also explains why host image copies off only hid it, by moving memory around. I'm running #1893 with host image copies ON on the RTX 4070 SUPER now (12 GB; it reproduced A in 7 of 7 runs without the switch): 2 runs of #1893 alone, 1 with #1849, and a control without #1893 on the same main. If #1893 clears A here too, this PR's NVIDIA default shouldn't land. I'd then reduce it to the plain switch, or close it in favour of #1810, and #1893 is the real fix. AI-assisted (Claude Code, Claude Opus 5.5). |
|
Data point for this PR, on a desktop RTX 5070 Ti 16 GB with NVIDIA 621.24 (Windows 11 Pro 26300, Ryzen 9 5900X, 48 GB, own 1.0.2.1). Counts only.
This doesn't contradict the 4070 SUPER result. If #1893's explanation holds (a copy that writes past the end of a D32 image), whether that write hits something that faults probably depends on what is bound after the image, which can differ between cards. Because the control boots didn't fail here, I didn't run #1893 on this card. AI-assisted. |
|
Thanks @Diegobecker07, that's useful: no loss with host copies on in 3 of 3 boots on a 16 GB 5070 Ti fits #1893's explanation. Whether the write past the D32 image faults depends on what's bound after it, which differs with VRAM size and allocation order. Right now on the 4070 SUPER (same driver, 621.24): a control boot of main without #1893, then #1893 ×2 with host copies on, then #1893 + #1849. If #1893 clears it here, I'll drop this PR's NVIDIA default. AI-assisted (Claude Code, Claude Opus 5.5). |
|
Merge order suggestion: #1893 first. If QemmHD's 4070 SUPER runs confirm that #1893 clears crash A with host image copy on, this PR could keep only the opt-in switch ( |
|
Retail data for the default question, from a 16 GB card: host image copies on did not lose the device here once #1893 was in, and leaving them off costs about 3.9 GB of VRAM at the world start. RTX 4080 16 GB, NVIDIA 621.24, Windows 11 26300, 32 GB RAM. Local merge of main b0f3d39 + #1849 #1893 #1889 #1860 #1886 #1882 #1887 and this PR;
All six got to the world start (frames stop, large compute pipelines build); none got further, so this says nothing about later crashes. Memory with
With the 2,048 MiB arena on top, the off run is at about 14.3 GB of 16 GB by 150 s, and in the other off run the log has "a 5594624-byte allocation did not fit in device-local memory and went to memory type 0". So on 16 GB the off default pushes allocations into shared memory around the world start; with copies on there is room left. Not checked: main without #1893 with copies on (so I cannot say #1893 is what makes it safe here), anything past the world start, more than one probe run per setting. The probe times differ (150 s and 237 s); the later one is the smaller, so the gap is not from running longer. AI-assisted (Claude Code). |
|
One detail to my table above: the 174 s run with copies on also had Snooozs's merge of #1592 with main and a translated fspx_gfx (16,914 programs); the other five runs are the merge exactly as listed. |
|
Thanks @OreoFR, @quartz-heron-58 and @abnalstlll-byte. #1893 has landed now, and quartz-heron-58's numbers settle the default question by themselves: host copies OFF cost about 3.9 GB of device-local memory at world start (12.3 GB vs 8.2 GB on a 4080), which pushes 12 GB cards into shared memory. So the NVIDIA AI-assisted (Claude Code, Claude Opus 5.5). |
|
Correction to my last comment, with data. I said I'd drop the NVIDIA default once #1893 was in; on the RTX 4070 SUPER it isn't that simple. On the build that lost the device in 7 of 7 runs with host copies on, adding #1893 changed nothing: 2 of 2 valid runs still lost the device with the same signature (WRITE_INVALID, same offset mod 2 MiB, same instruction-pointer entry; a third run was void). A log of every image-to-image copy at the patched spot shows no copy between two depth formats at all before the loss, so #1893 had nothing to act on here. On this card it's a different trigger from OreoFR's world-start one. That's also consistent with Diegobecker07's and quartz-heron-58's 16 GB cards not losing the device with copies on. The running tally on the 4070 SUPER: losses in 9 of 9 runs with host image copies, 0 of 8 without, and 0 of 1 with only the AI-assisted (Claude Code, Claude Opus 5.5). |
|
Correction to my last comment: two things I said there don't hold.
What stands: with host image copies enabled the loss happens every time on that build (11 of 11); with the extension unused it doesn't (0 of 2 there, 0 of 6 on newer mains). So, as OreoFR suggested for their case, what the switch changes is most likely placement: AI-assisted (Claude Code, Claude Opus 5.5). |
|
Test report from a combined build on a second NVIDIA machine. Counts only. Machine: Windows 11, RTX 4070 SUPER, NVIDIA 621.01, 64 GB, own 1.0.2.1 copy. Build: Shaders: translated on Pipeline cache: warm and complete, 26,503 of 26,503 (9.6 GB).
Recipe:
AI-assisted (Claude Code). |
|
Thanks @Tyrannys, that's the second RTX 4070 SUPER: with host image copies off ( AI-assisted (Claude Code, Claude Opus 5.5). |
|
Moving this back to draft. New evidence on the RTX 4070 SUPER suggests the host-image-copy switch doesn't address the root cause of the world-start loss here: with copies off, the runs simply never reached the stage where the loss happens. So the 0-of-8 is not evidence of a fix. Please don't merge on the strength of my earlier counts. I'll follow up once the root cause is confirmed and a proper fix is tested. AI-assisted (Claude Code, Claude Opus 5.5). |
|
Retail data from profile M (RTX 4070 Laptop 8 GB, NVIDIA 621.40, Windows 11). Merged onto |
|
A/B of this PR against main on one machine: same recipe, same pipeline cache folder, only the runtime executable changes (my recipe-diff tool reports exactly one difference). n=1 per side, indicative only. Note for reviewers, from reading main ec91d69: Reading (marked):
AI-assisted (Claude Code, Claude Opus 5.5) |
Depends on #1827 (DadaCap): without host image copies, title images only get filled once #1827 lands; otherwise they stay zero (verified by ecox982745 on an RTX 4090). Merge #1827 first.
The layer uses
VK_EXT_host_image_copyforWriteToSubresource/ReadFromSubresourcewhenever the device has the extension and itshostImageCopyfeature. On an RTX 4070 SUPER (Windows 11), a real boot lost the device with WRITE_INVALID in 7 of 7 runs that used host image copies and in 0 of 2 that didn't (481 s and 901 s, both still running at their time limits, up to 31,841ExecuteCommandListsand 7,960 presents). The mechanism is still open. Details, and what's been ruled out, are in #1608:What this adds:
LEONIDA_HOST_IMAGE_COPY.0: never.1: whenever available (the old behaviour).auto(the default; also for unset or unrecognised text): the same as1, except on NVIDIA (vendorID0x10DE), where it's off.When it's off, the extension is neither enabled nor chained, no image gets host-transfer usage, and every CPU texture copy takes the existing staging submit. That's exactly the path a device without the extension already takes. Device creation logs one line in place of the old "no VK_EXT_host_image_copy" line:
[rt] d3d12: host image copy: on|off (<reason>).Files
runtime/src/host_image_copy_policy.h(new): the choice as a pure function.runtime/test/host_image_copy_policy_test.cpp(new, registered ashost_image_copy_policy): the decision table (unset, empty,auto,0,1, other text) on NVIDIA, AMD and Intel, available and not.runtime/shims/d3d12_vulkan_device.cpp: uses the choice.runtime/README.mdanddocs/d3d12_vulkan.md: the variable, and whyautois off on NVIDIA.Tested (Windows 11, RTX 4070 SUPER, MSVC RelWithDebInfo):
ctest -j 4: 415/416. The only failure isd3d12_depth_resolve, the known NVIDIA MFAA sample-position case (d3d12_depth_resolve_test: the host's edge draw takes the standard 4x sample positions (TEST-DEPTH-RESOLVE-SAMPLE-POSITIONS) #1505).autoand other text logoff (auto: NVIDIA);=0and=1log their own reason.test_runtime_pathsfailure).check_no_game_data.pyis clean.Cost and caveats
=1and with the default), and reports from AMD/Intel on whetherautoshould stay NVIDIA-only, are very welcome. If the mechanism turns out to be a layer usage error, the right fix replaces this default.Claimed in #1608 as RT-HOST-IMAGE-COPY-SWITCH.
AI-assisted (Claude Code, Claude Opus 5.5).
🤖 Generated with Claude Code
https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf