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

Closed
opened 2026-11-26 20:21:06 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1364
Author: @qhukz13
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142

Base: main ← Head: cont/old-4682


📝 Commits (3)

  • 7eb642a runtime: fall back to staging copies when a HOST_TRANSFER image has no memory type
  • bd53fce Runtime: port #3077's forced host-transfer retry into the staging fallback
  • c3c5c82 d3d12: drop the stale tier-1 doc row and keep fallback logs honest

📊 Changes

5 files changed (+81 additions, -17 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+6 -0)
📝 runtime/shims/d3d12_com.h (+3 -0)
📝 runtime/shims/d3d12_vulkan_device.cpp (+41 -7)
📝 runtime/test/d3d12_subresource_copy_test.cpp (+14 -4)
📝 runtime/test/d3d12_vulkan_device_test.cpp (+17 -6)

📄 Description

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


🔄 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/1364 **Author:** [@qhukz13](https://github.com/qhukz13) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `cont/old-4682` --- ### 📝 Commits (3) - [`7eb642a`](https://github.com/ubiquitarianism/leonida/commit/7eb642a87aa9c7c65ce4723aa7101c4f76115404) runtime: fall back to staging copies when a HOST_TRANSFER image has no memory type - [`bd53fce`](https://github.com/ubiquitarianism/leonida/commit/bd53fcee307e65878f5048f12934f2ba1f5d0b86) Runtime: port #3077's forced host-transfer retry into the staging fallback - [`c3c5c82`](https://github.com/ubiquitarianism/leonida/commit/c3c5c82759ce0334a799fe8ec312ca06fef80e91) d3d12: drop the stale tier-1 doc row and keep fallback logs honest ### 📊 Changes **5 files changed** (+81 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+6 -0) 📝 `runtime/shims/d3d12_com.h` (+3 -0) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+41 -7) 📝 `runtime/test/d3d12_subresource_copy_test.cpp` (+14 -4) 📝 `runtime/test/d3d12_vulkan_device_test.cpp` (+17 -6) </details> ### 📄 Description 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:21:06 +01:00
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#1394
No description provided.