[PR #37] [CLOSED] runtime: fall back to staging copies when a HOST_TRANSFER image has no memory type (TEST-995) #90

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/37
Author: @Andretuta
Created: 11/24/2026
Status: ❌ Closed

Base: main ← Head: old-pr/4682


📝 Commits (3)

  • 9c69b41 runtime: fall back to staging copies when a HOST_TRANSFER image has no memory type
  • 4469dbc Runtime: port #3077's forced host-transfer retry into the staging fallback
  • 310fa80 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

Carried over from old PR 4682 by ray3242 in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/4682, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
ray3242: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

��Item: TEST-995 �^C�� claim: https://github.com/ItsNotRexed/Leonida/issues/4571#issuecomment-7091273076 (found by me in #4420).

Depends on: #5000 (the known pre-existing tier-1 heap_mismatches assertion in d3d12_vulkan_device_test is fixed there; this PR's own fallback path is complete without it).

Head 310fa807 is based on 0db7fed5 and is not rebased onto the current main 561b65a8 (merge base 0db7fed5, 1815 commits behind); it remains mergeable. The body had a cp1252 round-trip mangling; rewritten as UTF-8. I will rebase when a maintainer asks rather than force-push a branch that reviewers have already validated at this head.

What and why

On NVIDIA Pascal (GTX 1060 / 582.78, GTX 1050 Ti / 560.94 and 582.78), a texture in a CPU-visible heap advertises VK_FORMAT_FEATURE_2_HOST_IMAGE_TRANSFER_BIT_EXT, vkCreateImage succeeds, but vkGetImageMemoryRequirements returns memoryTypeBits = 0 (no memory type at all). CreateCommittedResource then returned E_OUTOFMEMORY. The Vulkan SDK 1.4.363 validation layer reports nothing.

runtime/shims/d3d12_vulkan_device.cpp now recreates such an unbound image without VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT (re-checking format support first) and continues on the staging-copy path. A failed vkCreateImage leaves image_ null so the destructor cannot free an undefined handle. The retry loop also handles an allocation/bind failure with the same fallback, and log_once reports which branch fired.

With @gustavorafaelschmidt's go-ahead, the permanent test-only force_host_transfer_retry path from their #3077 commit is included here (commit authored by them, 4469dbca), so both d3d12_subresource_copy_test and d3d12_vulkan_device_test run their CPU copies through three paths: normal host copy, explicit staging, and forced no-memory-type. The tier-1 heap/WARP changes in #3077 are deliberately not ported �^C�� they belong to D3D-504 (#5000).

Tested

Windows 11, NVIDIA GeForce GTX 1060 6GB, driver 582.78, Vulkan 1.4.312 / headers 1.4.363, MSVC 19.44 + Ninja, RelWithDebInfo:

  • d3d12_subresource_copy_test: OK �^C�� three paths, 109 compared steps each, 0 mismatches.
  • d3d12_vulkan_device_test: three CPU-copy paths matched; the only failure is the known pre-existing tier-1 heap_mismatches assert (D3D-504), fixed by #5000. git diff --check clean.

Independent confirmations on this PR:

  • @shdann: fault injection of both branches (pass on head, fail on base);
  • @Codejustcode12 (GTX 1050 Ti / 560.94): natural empty mask on formats 37/133/98, all three paths 0 mismatches, no VUIDs, and main + #4682 + #5000 green on Pascal;
  • @thehollowedone (RTX 3080 Ti / 621.35) and @Krashgamer (RTX 3080 / 610.88): all three paths matched native D3D12, no VUIDs; Krashgamer's negative control (restoring main's E_OUTOFMEMORY) makes both executables fail.

AI-assisted (OpenCode). Synthetic fixtures only; no game data.

  • @auswhalen999-debug (GTX 1070 8 GB / driver 581.80, Windows 11, clang-cl 23.1.6, head 310fa807 merged with main 8f208d09a): clean main reproduces #4420 on this card; this PR gives 109/109 steps with 0 mismatches on all three copy paths and fixes the two CUSTOM heap E_OUTOFMEMORY cases; main + #4682 + #5000 makes d3d12_vulkan_device_test 100% green. Natural empty masks on formats 37/133.

🔄 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/37 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `old-pr/4682` --- ### 📝 Commits (3) - [`9c69b41`](https://github.com/ubiquitarianism/leonida/commit/9c69b416d88e8efa83dff7c8eefcd3b4c7e6a5ef) runtime: fall back to staging copies when a HOST_TRANSFER image has no memory type - [`4469dbc`](https://github.com/ubiquitarianism/leonida/commit/4469dbcac7de7a410da042b5ede956a2f2e858c8) Runtime: port #3077's forced host-transfer retry into the staging fallback - [`310fa80`](https://github.com/ubiquitarianism/leonida/commit/310fa8076e5103485c01f95a8417fcc6574b2951) 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 > Carried over from **old PR 4682** by `ray3242` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/4682`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `ray3242`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): ��Item: **TEST-995** �^C�� claim: https://github.com/ItsNotRexed/Leonida/issues/4571#issuecomment-7091273076 (found by me in `#4420`). Depends on: `#5000` (the known pre-existing tier-1 `heap_mismatches` assertion in `d3d12_vulkan_device_test` is fixed there; this PR's own fallback path is complete without it). Head `310fa807` is based on `0db7fed5` and is not rebased onto the current `main` `561b65a8` (merge base `0db7fed5`, 1815 commits behind); it remains mergeable. The body had a cp1252 round-trip mangling; rewritten as UTF-8. I will rebase when a maintainer asks rather than force-push a branch that reviewers have already validated at this head. ### What and why On NVIDIA Pascal (GTX 1060 / 582.78, GTX 1050 Ti / 560.94 and 582.78), a texture in a CPU-visible heap advertises `VK_FORMAT_FEATURE_2_HOST_IMAGE_TRANSFER_BIT_EXT`, `vkCreateImage` succeeds, but `vkGetImageMemoryRequirements` returns `memoryTypeBits = 0` (no memory type at all). `CreateCommittedResource` then returned `E_OUTOFMEMORY`. The Vulkan SDK 1.4.363 validation layer reports nothing. `runtime/shims/d3d12_vulkan_device.cpp` now recreates such an unbound image without `VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT` (re-checking format support first) and continues on the staging-copy path. A failed `vkCreateImage` leaves `image_` null so the destructor cannot free an undefined handle. The retry loop also handles an allocation/bind failure with the same fallback, and `log_once` reports which branch fired. With `@gustavorafaelschmidt`'s go-ahead, the permanent test-only `force_host_transfer_retry` path from their `#3077` commit is included here (commit authored by them, `4469dbca`), so both `d3d12_subresource_copy_test` and `d3d12_vulkan_device_test` run their CPU copies through three paths: normal host copy, explicit staging, and forced no-memory-type. The tier-1 heap/WARP changes in `#3077` are deliberately not ported �^C�� they belong to D3D-504 (`#5000`). ### Tested Windows 11, **NVIDIA GeForce GTX 1060 6GB, driver 582.78**, Vulkan 1.4.312 / headers 1.4.363, MSVC 19.44 + Ninja, RelWithDebInfo: - `d3d12_subresource_copy_test: OK` �^C�� three paths, 109 compared steps each, 0 mismatches. - `d3d12_vulkan_device_test`: three CPU-copy paths matched; the only failure is the known pre-existing tier-1 `heap_mismatches` assert (D3D-504), fixed by `#5000`. `git diff --check` clean. Independent confirmations on this PR: - `@shdann`: fault injection of both branches (pass on head, fail on base); - `@Codejustcode12` (GTX 1050 Ti / 560.94): natural empty mask on formats 37/133/98, all three paths 0 mismatches, no VUIDs, and main + `#4682` + `#5000` green on Pascal; - `@thehollowedone` (RTX 3080 Ti / 621.35) and `@Krashgamer` (RTX 3080 / 610.88): all three paths matched native D3D12, no VUIDs; Krashgamer's negative control (restoring main's `E_OUTOFMEMORY`) makes both executables fail. AI-assisted (OpenCode). Synthetic fixtures only; no game data. - `@auswhalen999-debug` (GTX 1070 8 GB / driver 581.80, Windows 11, clang-cl 23.1.6, head `310fa807` merged with main `8f208d09a`): clean main reproduces `#4420` on this card; this PR gives 109/109 steps with 0 mismatches on all three copy paths and fixes the two CUSTOM heap E_OUTOFMEMORY cases; main + `#4682` + `#5000` makes `d3d12_vulkan_device_test` 100% green. Natural empty masks on formats 37/133. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:16:46 +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#90
No description provided.