runtime: fall back to staging copies when a HOST_TRANSFER image has no memory type (OLD-4682) #1364

Merged
qhukz13 merged 3 commits from upstream-pr/1364 into main 2026-11-24 23:15:03 +00:00
qhukz13 commented 2026-11-24 22:35:59 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by qhukz13 on 2026-11-24T22:35:59Z.


Claimed in the coordination issue as: OLD-4682 (claim)

Carries #37 (old-pr/4682, TEST-995) onto current main. The three commits are cherry-picked unchanged with their
authors: ray3242 (the fallback), Gustavo Rafael Schmidt (the forced retry the tests use) and Rayhan Robin (log
wording, stale doc row). The only conflict was in docs/testing.md, where the first commit added a row about the
resource-heap-tier-1 comparison that the third commit removes again; the row is left out. #37 can be closed when
this lands.

What and why

On NVIDIA Pascal, a texture in a CPU-visible heap (CUSTOM write-back or write-combine, L0) is a texture the CPU reads
and writes with WriteToSubresource / ReadFromSubresource. The layer creates it with
VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT when the format reports VK_FORMAT_FEATURE_2_HOST_IMAGE_TRANSFER_BIT_EXT;
vkCreateImage succeeds, but vkGetImageMemoryRequirements then returns memoryTypeBits = 0, so no memory type
can back it and CreateCommittedResource answers E_OUTOFMEMORY where D3D12 creates the texture. The same image
without host-transfer usage takes device-local memory (memoryTypeBits = 0x82 on the card below).

Resource::create_texture now remakes such an unbound image without host-transfer usage and continues on the
staging-copy path, the one a device without VK_EXT_host_image_copy already uses. A failed vkCreateImage leaves
image_ null. VulkanDeviceInfo::force_host_transfer_retry lets d3d12_vulkan_device_test and
d3d12_subresource_copy_test take this branch on any GPU (their third CPU-copy path), so it is covered where the
driver does not reproduce it.

Tested

GeForce GTX 1050 Ti 4 GB (Pascal, no Resizable BAR), NVIDIA 582.66, Windows 10 Pro 19045, MSVC (VS 2022 Build
Tools), RelWithDebInfo. main at 4a50cafc7 against this branch, each test run 3 times
(ctest --repeat until-fail:3):

test main this branch
d3d12_subresource_copy fails (line 391, CPU copies (host image copy): the steps differ from the host's) passes, 3 of 3
d3d12_heap_properties, committed texture, CUSTOM write-back L0 and write-combine L0 ours 0x8007000e host 0x0 match the host
d3d12_vulkan_device, the CPU-heap texture (line 174) and the CPU copies (line 7046) fail pass; WriteToSubresource/ReadFromSubresource (staging copy): ... matched

The layer logs host-transfer image has no memory type; using staging copies, format 37 (and format 133) on this
card. root_sig and d3d12_state_sweep fail identically on both sides (this Windows 10 runtime refuses the
per-face stencil pipelines the layer accepts). Still failing on both, and not part of this PR: the
resource-heap-tier-1 comparisons, ALLOW_ALL heaps in d3d12_heap_properties and heap_mismatches (line 7330) in
d3d12_vulkan_device; on main the latter is not reached because the test stops at the CPU-heap texture first.

#37 also lists independent runs on a GTX 1060 6 GB (582.78), a GTX 1070 (581.80), a GTX 1050 Ti (560.94), an
RTX 3080 Ti and an RTX 3080, on its original base.

GPUs tested: NVIDIA GeForce GTX 1050 Ti, driver 582.66, Windows 10 19045. No game files.

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly.
  • One topic.
  • No game data, keys or decryption (CONTRIBUTING.md).
  • A new translator rule is in the contract table of docs/design.md. (No translator change; the behaviour is
    documented in docs/d3d12_vulkan.md.)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5481481186 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1364). Originally posted by [qhukz13](https://github.com/qhukz13) on 2026-11-24T22:35:59Z. --- Claimed in the coordination issue as: OLD-4682 ([claim](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7146403034)) Carries #37 (`old-pr/4682`, TEST-995) onto current `main`. The three commits are cherry-picked unchanged with their authors: ray3242 (the fallback), Gustavo Rafael Schmidt (the forced retry the tests use) and Rayhan Robin (log wording, stale doc row). The only conflict was in `docs/testing.md`, where the first commit added a row about the resource-heap-tier-1 comparison that the third commit removes again; the row is left out. #37 can be closed when this lands. ### What and why On NVIDIA Pascal, a texture in a CPU-visible heap (CUSTOM write-back or write-combine, L0) is a texture the CPU reads and writes with `WriteToSubresource` / `ReadFromSubresource`. The layer creates it with `VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT` when the format reports `VK_FORMAT_FEATURE_2_HOST_IMAGE_TRANSFER_BIT_EXT`; `vkCreateImage` succeeds, but `vkGetImageMemoryRequirements` then returns `memoryTypeBits = 0`, so no memory type can back it and `CreateCommittedResource` answers `E_OUTOFMEMORY` where D3D12 creates the texture. The same image without host-transfer usage takes device-local memory (`memoryTypeBits = 0x82` on the card below). `Resource::create_texture` now remakes such an unbound image without host-transfer usage and continues on the staging-copy path, the one a device without `VK_EXT_host_image_copy` already uses. A failed `vkCreateImage` leaves `image_` null. `VulkanDeviceInfo::force_host_transfer_retry` lets `d3d12_vulkan_device_test` and `d3d12_subresource_copy_test` take this branch on any GPU (their third CPU-copy path), so it is covered where the driver does not reproduce it. ### Tested GeForce GTX 1050 Ti 4 GB (Pascal, no Resizable BAR), NVIDIA 582.66, Windows 10 Pro 19045, MSVC (VS 2022 Build Tools), RelWithDebInfo. `main` at `4a50cafc7` against this branch, each test run 3 times (`ctest --repeat until-fail:3`): | test | `main` | this branch | |---|---|---| | `d3d12_subresource_copy` | fails (line 391, `CPU copies (host image copy): the steps differ from the host's`) | passes, 3 of 3 | | `d3d12_heap_properties`, `committed texture, CUSTOM write-back L0` and `write-combine L0` | `ours 0x8007000e host 0x0` | match the host | | `d3d12_vulkan_device`, the CPU-heap texture (line 174) and the CPU copies (line 7046) | fail | pass; `WriteToSubresource/ReadFromSubresource (staging copy): ... matched` | The layer logs `host-transfer image has no memory type; using staging copies, format 37` (and format 133) on this card. `root_sig` and `d3d12_state_sweep` fail identically on both sides (this Windows 10 runtime refuses the per-face stencil pipelines the layer accepts). Still failing on both, and not part of this PR: the resource-heap-tier-1 comparisons, `ALLOW_ALL` heaps in `d3d12_heap_properties` and `heap_mismatches` (line 7330) in `d3d12_vulkan_device`; on `main` the latter is not reached because the test stops at the CPU-heap texture first. #37 also lists independent runs on a GTX 1060 6 GB (582.78), a GTX 1070 (581.80), a GTX 1050 Ti (560.94), an RTX 3080 Ti and an RTX 3080, on its original base. GPUs tested: NVIDIA GeForce GTX 1050 Ti, driver 582.66, Windows 10 19045. No game files. AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly. - [x] One topic. - [x] No game data, keys or decryption (CONTRIBUTING.md). - [ ] A new translator rule is in the contract table of `docs/design.md`. (No translator change; the behaviour is documented in `docs/d3d12_vulkan.md`.) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
aslan2142 commented 2026-11-24 23:15:06 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-24T23:15:06Z.


Merged. Thanks for carrying this forward with the original authors kept on their commits.

  • Claim: valid. OLD-4682 was posted at 22:34 UTC, a minute before this PR, and is unedited. Nobody else had claimed it.
  • Same change as old-pr/4682: the added and removed lines are identical. The only difference is the docs/testing.md row that one commit added and a later one removed.
  • The change holds up: an image whose host-transfer usage leaves it with no memory type is destroyed and created once more without that usage, and both directions (writes and read-backs) follow host_transfer_ in the one function that does them. A real allocation failure still returns E_OUTOFMEMORY after the single retry. Nothing changes where host copies work.
  • Windows suite under Wine (clang-cl; llvmpipe and an RDNA2 iGPU, RADV), main 28a32e190 + this PR against that main: no test changed state on either device. d3d12_subresource_copy and d3d12_vulkan_device pass on both; on the iGPU all three copy paths ran (host image copy, staging, and the forced fallback) with 0 mismatches in 109 steps each.
  • On today's main d9f0a98e1 + c3c5c8275: it merges cleanly; the 13 docs and writer tests pass; check_no_game_data.py is clean on the 5 changed files. The merges into main since that suite run do not touch the files this PR changes.
  • Not measured here: the real case, an NVIDIA Pascal driver that gives the empty mask by itself, and native Windows. Those rest on the author's GTX 1050 Ti run and the NVIDIA runs listed on #37.
  • CI had not finished on this head.

A small follow-up if you like: the new docs/d3d12_vulkan.md row says driver 582.78 for the GTX 1050 Ti, while the run in the description was on 582.66.

#37, the carried-over draft of the same patch, is closed in favour of this one.

AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7147186887 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1364#issuecomment-7147186887). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-24T23:15:06Z. --- Merged. Thanks for carrying this forward with the original authors kept on their commits. - **Claim:** valid. `OLD-4682` was posted at 22:34 UTC, a minute before this PR, and is unedited. Nobody else had claimed it. - **Same change as `old-pr/4682`:** the added and removed lines are identical. The only difference is the `docs/testing.md` row that one commit added and a later one removed. - **The change holds up:** an image whose host-transfer usage leaves it with no memory type is destroyed and created once more without that usage, and both directions (writes and read-backs) follow `host_transfer_` in the one function that does them. A real allocation failure still returns `E_OUTOFMEMORY` after the single retry. Nothing changes where host copies work. - **Windows suite under Wine** (clang-cl; llvmpipe and an RDNA2 iGPU, RADV), `main` `28a32e190` + this PR against that `main`: no test changed state on either device. `d3d12_subresource_copy` and `d3d12_vulkan_device` pass on both; on the iGPU all three copy paths ran (host image copy, staging, and the forced fallback) with 0 mismatches in 109 steps each. - **On today's `main` `d9f0a98e1` + `c3c5c8275`:** it merges cleanly; the 13 docs and writer tests pass; `check_no_game_data.py` is clean on the 5 changed files. The merges into `main` since that suite run do not touch the files this PR changes. - **Not measured here:** the real case, an NVIDIA Pascal driver that gives the empty mask by itself, and native Windows. Those rest on the author's GTX 1050 Ti run and the NVIDIA runs listed on #37. - **CI had not finished on this head.** A small follow-up if you like: the new `docs/d3d12_vulkan.md` row says driver 582.78 for the GTX 1050 Ti, while the run in the description was on 582.66. #37, the carried-over draft of the same patch, is closed in favour of this one. AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5).
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!1364
No description provided.