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

Closed
github-bot wants to merge 3 commits from gh-pr/37/head into gh-pr/37/base
Owner

@⁠Andretuta on GitHub · 2026-11-24 02:04 UTC · original
ubiquitarianism:old-pr/4682 → main · +81 −17 · 5 files · 3 commits · closed without merging

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.
**@⁠Andretuta** on GitHub · 2026-11-24 02:04 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/37) `ubiquitarianism:old-pr/4682` → `main` · +81 −17 · 5 files · 3 commits · closed without merging > 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.
Ported from @gustavorafaelschmidt's #3077 commit 2612b150 (author credited
below). With their go-ahead on #4682, keep one fix for both the empty-mask
driver case and the allocation-failure case this PR already handled:

- VulkanDeviceInfo::force_host_transfer_retry (tests only) forces the
  no-memory-type branch on any GPU, so d3d12_vulkan_device_test and
  d3d12_subresource_copy_test run their CPU copies through a third path.
- create_image() is a lambda that leaves image_ null after a failed create
  (the handle is undefined on failure and ~Resource destroys any non-null
  one), and log_once reports when the fallback fires.
- After dropping host-transfer usage, check_image_support is re-run before
  the image is made again; this PR's allocation/bind-failure retry is kept
  alongside it.
- docs/d3d12_vulkan.md and docs/testing.md record the Pascal measurement and
  the tier-1 host note.

The tier-1 heap/WARP comparison changes in #3077 are not part of this port:
they belong to D3D-504 (#5000). Tests on GTX 1060 / 582.78: both executables
built with MSVC 19.44; d3d12_subresource_copy_test OK with all three paths
(109 compared steps, 0 mismatches each); d3d12_vulkan_device_test's three
CPU-copy paths matched, with only the known pre-existing tier-1
heap_mismatches assert (D3D-504) still failing. No game data.

AI-assisted (OpenCode).

Original commit by Gustavo Rafael Schmidt <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:41:52 +00:00
github-bot closed this pull request 2026-11-26 08:41:52 +00:00
Author
Owner

@⁠qhukz13 on GitHub · 2026-11-24 22:36 UTC · original

These three commits are carried onto current main in #1364 (claim OLD-4682), cherry-picked unchanged with your authorship; the only conflict was the docs/testing.md row the third commit removes anyway. Re-measured there on a GTX 1050 Ti (NVIDIA 582.66, Windows 10): d3d12_subresource_copy and the CPU-heap texture cases of d3d12_heap_properties and d3d12_vulkan_device fail on main and pass with it. If you would rather carry it yourselves, say so and I will close mine. AI-assisted (Claude Code).

**@⁠qhukz13** on GitHub · 2026-11-24 22:36 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/37#issuecomment-7146439220) These three commits are carried onto current `main` in #1364 (claim OLD-4682), cherry-picked unchanged with your authorship; the only conflict was the `docs/testing.md` row the third commit removes anyway. Re-measured there on a GTX 1050 Ti (NVIDIA 582.66, Windows 10): `d3d12_subresource_copy` and the CPU-heap texture cases of `d3d12_heap_properties` and `d3d12_vulkan_device` fail on `main` and pass with it. If you would rather carry it yourselves, say so and I will close mine. AI-assisted (Claude Code).
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-24 23:15 UTC · original

Closing this carried-over draft: the same three commits, with their original authors, were carried onto current main in #1364 (claim OLD-4682), and #1364 is merged now.

The NVIDIA runs recorded here were part of what #1364's merge rested on. Thanks to everyone who tested it.

AI-assisted (Claude Code, Claude Fable 5.2).

**@⁠aslan2142** on GitHub · 2026-11-24 23:15 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/37#issuecomment-7147189753) Closing this carried-over draft: the same three commits, with their original authors, were carried onto current `main` in #1364 (claim `OLD-4682`), and #1364 is merged now. The NVIDIA runs recorded here were part of what #1364's merge rested on. Thanks to everyone who tested it. AI-assisted (Claude Code, Claude Fable 5.2).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.