[PR #1851] d3d12: LEONIDA_HOST_IMAGE_COPY switch; auto leaves host image copies off on NVIDIA #1863

Open
opened 2026-11-26 21:19:13 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1851
Author: @QemmHD
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: claude/host-image-copy-switch


📝 Commits (1)

  • 59c1586 d3d12: LEONIDA_HOST_IMAGE_COPY switch, auto off on NVIDIA

📊 Changes

6 files changed (+116 additions, -3 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+8 -0)
📝 runtime/CMakeLists.txt (+4 -0)
📝 runtime/README.md (+1 -0)
📝 runtime/shims/d3d12_vulkan_device.cpp (+8 -3)
➕ runtime/src/host_image_copy_policy.h (+33 -0)
➕ runtime/test/host_image_copy_policy_test.cpp (+62 -0)

📄 Description

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_copy for WriteToSubresource/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 didn't (481 s and 901 s, both still running at their time limits, up to 31,841 ExecuteCommandLists and 7,960 presents). The mechanism is still open. Details, and what's been ruled out, are in #1608:

  • not a translated store (store trace over every program);
  • no buffer device address near the fault;
  • not a mapping the layer made;
  • not the caller memory of recent host copies;
  • no image bound past its memory;
  • no validation-layer error about host copies or memory.

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 as 1, except on NVIDIA (vendorID 0x10DE), 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 as host_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.md and docs/d3d12_vulkan.md: the variable, and why auto is off on NVIDIA.

Tested (Windows 11, RTX 4070 SUPER, MSVC RelWithDebInfo):

  • The new test passes.
  • Full ctest -j 4: 415/416. The only failure is d3d12_depth_resolve, the known NVIDIA MFAA sample-position case (#1505).
  • Through the real layer device: unset, auto and other text log off (auto: NVIDIA); =0 and =1 log their own reason.
  • The consistency set is the same as main (its one pre-existing test_runtime_paths failure).
  • check_no_game_data.py is clean.

Cost and caveats

  • Staging uploads make the long loads slower.
  • The default leaves host copies unexercised on NVIDIA. The test harnesses that build their own device still cover them.
  • Replications on other NVIDIA cards (with =1 and with the default), and reports from AMD/Intel on whether auto should 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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1851 **Author:** [@QemmHD](https://github.com/QemmHD) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `claude/host-image-copy-switch` --- ### 📝 Commits (1) - [`59c1586`](https://github.com/ubiquitarianism/leonida/commit/59c1586d4ede89e93cacf8788becfe6662aa4c25) d3d12: LEONIDA_HOST_IMAGE_COPY switch, auto off on NVIDIA ### 📊 Changes **6 files changed** (+116 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+8 -0) 📝 `runtime/CMakeLists.txt` (+4 -0) 📝 `runtime/README.md` (+1 -0) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+8 -3) ➕ `runtime/src/host_image_copy_policy.h` (+33 -0) ➕ `runtime/test/host_image_copy_policy_test.cpp` (+62 -0) </details> ### 📄 Description **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_copy` for `WriteToSubresource`/`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 didn't (481 s and 901 s, both still running at their time limits, up to 31,841 `ExecuteCommandLists` and 7,960 presents). The mechanism is still open. Details, and what's been ruled out, are in #1608: - not a translated store (store trace over every program); - no buffer device address near the fault; - not a mapping the layer made; - not the caller memory of recent host copies; - no image bound past its memory; - no validation-layer error about host copies or memory. **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 as `1`, except on NVIDIA (vendorID `0x10DE`), 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 as `host_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.md` and `docs/d3d12_vulkan.md`: the variable, and why `auto` is off on NVIDIA. **Tested** (Windows 11, RTX 4070 SUPER, MSVC RelWithDebInfo): - The new test passes. - Full `ctest -j 4`: 415/416. The only failure is `d3d12_depth_resolve`, the known NVIDIA MFAA sample-position case (#1505). - Through the real layer device: unset, `auto` and other text log `off (auto: NVIDIA)`; `=0` and `=1` log their own reason. - The consistency set is the same as main (its one pre-existing `test_runtime_paths` failure). - `check_no_game_data.py` is clean. **Cost and caveats** - Staging uploads make the long loads slower. - The default leaves host copies unexercised on NVIDIA. The test harnesses that build their own device still cover them. - Replications on other NVIDIA cards (with `=1` and with the default), and reports from AMD/Intel on whether `auto` should 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.com/claude-code) https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#1863
No description provided.