d3d12: stage title textures when their format or usage rules out host copies #1894

Merged
ecox982745 merged 35 commits from upstream-pr/1894 into main 2026-11-29 15:43:14 +00:00
ecox982745 commented 2026-11-25 14:52:52 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ecox982745 on 2026-11-25T14:52:52Z.


Claimed as RT-TITLE-STAGED-PER-FORMAT in the coordination issue. This addresses the format-specific follow-up from the #1827 merge note.

Depends on: #1827 (merged).

What and why

A Vulkan device can expose host image copy and still refuse it for a particular format or combination of image usages. In that case the runtime successfully created the image without host-transfer usage, but a subsequent title-texture refresh skipped its upload. Both a linear movie-plane fixture and a tiled compressed image returned incorrect bytes.

The runtime selects mandatory staging when the format, image usage or compatible memory types rule out host transfer. A GTX 1050 Ti reported no bindable memory type for a host-transfer R8 movie plane. Pascal hardware report A CPU-visible, single-sampled colour title image can use ordinary image memory and queue the upload when host transfer is unavailable. Images that can use either path retain the existing placement heuristic and host-backing retry. An allocation failure on an image that requires staging propagates normally.

Tested

Windows 11, NVIDIA GeForce RTX 4090 (616.64), MSVC 19.44. The test keeps host image copy enabled on the real device. A test shim masks the R8 format feature and separately rejects host-transfer usage in the BC1 image-support query.

  • On main 446574e76 with only the new test, d3d12_existing_heap failed both readbacks: the persistently mapped R8 plane and the four-mip, two-slice BC1 array.
  • At 14f04ce2d, both readbacks pass. All three existing heap CTests passed (default, write watch disabled, write watch enabled), including the unmasked controls.
  • At 06ba2eb2d, a test shim reproduced the Pascal driver's empty memory type mask for a 256×8 R8 image. The previous head failed the pixel check. All three existing-heap CTests passed on the RTX 4090 with the fix, both with and without Vulkan validation. RTX 4090 test details
  • At the same revision, @qhukz13 reran all three existing-heap tests on a physical GTX 1050 Ti, Windows 10, NVIDIA 582.66. Each test passed three times with Vulkan validation enabled and three times with it disabled (18/18). The tester reported no validation messages. Instrumenting the earlier revision showed an empty memory type mask for R8, RGBA8 and BC1 title images. GTX 1050 Ti results
  • At 2d258c8cd, the fallback logs the Vulkan format once per process for each affected format. The same three tests passed on the RTX 4090 with validation enabled and disabled (6/6). The shim produced exactly one format 9 (R8) fallback message in each test process.
  • CPU semantic suite: 6,288 tests across 489 files, zero failing files. Documentation links: 16 passed. Line-ending tests: 3 passed. The no-game-data check and git diff --check passed.

All texture inputs are synthetic. These tests exercise format-specific uploads and pixel readback on the reported GPUs.

AI-assisted: OpenAI Codex (gpt-6.2-astra).

Checklist

  • Based on current main and checked for a clean merge.
  • One topic.
  • No game data, keys or decryption.
  • No shader translator rule changed.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5493694008 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1894). Originally posted by [ecox982745](https://github.com/ecox982745) on 2026-11-25T14:52:52Z. --- Claimed as `RT-TITLE-STAGED-PER-FORMAT` in [the coordination issue](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7165771692). This addresses the format-specific follow-up from the [#1827 merge note](https://github.com/ubiquitarianism/leonida/pull/1827#issuecomment-7165579561). Depends on: #1827 (merged). ### What and why A Vulkan device can expose host image copy and still refuse it for a particular format or combination of image usages. In that case the runtime successfully created the image without host-transfer usage, but a subsequent title-texture refresh skipped its upload. Both a linear movie-plane fixture and a tiled compressed image returned incorrect bytes. The runtime selects mandatory staging when the format, image usage or compatible memory types rule out host transfer. A GTX 1050 Ti reported no bindable memory type for a host-transfer R8 movie plane. [Pascal hardware report](https://github.com/ubiquitarianism/leonida/pull/1894#issuecomment-7172992761) A CPU-visible, single-sampled colour title image can use ordinary image memory and queue the upload when host transfer is unavailable. Images that can use either path retain the existing placement heuristic and host-backing retry. An allocation failure on an image that requires staging propagates normally. ### Tested Windows 11, NVIDIA GeForce RTX 4090 (616.64), MSVC 19.44. The test keeps host image copy enabled on the real device. A test shim masks the R8 format feature and separately rejects host-transfer usage in the BC1 image-support query. - On main `446574e76` with only the new test, `d3d12_existing_heap` failed both readbacks: the persistently mapped R8 plane and the four-mip, two-slice BC1 array. - At `14f04ce2d`, both readbacks pass. All three existing heap CTests passed (default, write watch disabled, write watch enabled), including the unmasked controls. - At `06ba2eb2d`, a test shim reproduced the Pascal driver's empty memory type mask for a 256×8 R8 image. The previous head failed the pixel check. All three existing-heap CTests passed on the RTX 4090 with the fix, both with and without Vulkan validation. [RTX 4090 test details](https://github.com/ubiquitarianism/leonida/pull/1894#issuecomment-7173571345) - At the same revision, @qhukz13 reran all three existing-heap tests on a physical GTX 1050 Ti, Windows 10, NVIDIA 582.66. Each test passed three times with Vulkan validation enabled and three times with it disabled (18/18). The tester reported no validation messages. Instrumenting the earlier revision showed an empty memory type mask for R8, RGBA8 and BC1 title images. [GTX 1050 Ti results](https://github.com/ubiquitarianism/leonida/pull/1894#issuecomment-7174515492) - At `2d258c8cd`, the fallback logs the Vulkan format once per process for each affected format. The same three tests passed on the RTX 4090 with validation enabled and disabled (6/6). The shim produced exactly one format 9 (R8) fallback message in each test process. - CPU semantic suite: 6,288 tests across 489 files, zero failing files. Documentation links: 16 passed. Line-ending tests: 3 passed. The no-game-data check and `git diff --check` passed. All texture inputs are synthetic. These tests exercise format-specific uploads and pixel readback on the reported GPUs. AI-assisted: OpenAI Codex (`gpt-6.2-astra`). ### Checklist - [x] Based on current main and checked for a clean merge. - [x] One topic. - [x] No game data, keys or decryption. - No shader translator rule changed.
Tyrannys commented 2026-11-25 18:12:08 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tyrannys on 2026-11-25T18:12:08Z.


Test report from a combined build on a second NVIDIA machine. Counts only.

Machine: Windows 11, RTX 4070 SUPER, NVIDIA 621.01, 64 GB, own 1.0.2.1 copy.

Build: main fe1553456 (already contains #1827 and #1893), plus #674, #1662, #1851, #1849, #1905, #1957, #1950, #1886 and #1894. All of them merged without conflicts.

Shaders: translated on 3de22a190 + #674 + #1662 with --wave64-emulate. 29,279 of 29,280 translated, and all 29,279 pass spirv-val. That is 2,683 library programs and 29 of 29 FSPX. main's translator changes since then are correctness fixes only.

Pipeline cache: warm and complete, 26,503 of 26,503 (9.6 GB).

  • Three library compute programs took 30 to 32 minutes each to build alone: the ScreenProbes ActivateRays, ActivateProbes and ActivateProbesTarget programs of indirect diffuse lighting.
  • Building all three at once crashed the NVIDIA compiler ("NVVM compilation failed: 3", after 22 minutes).

Recipe: scripts/windows-boot/boot.ps1 -Seconds 480, LEONIDA_KEYBOARD_PAD=1 LEONIDA_SKIP_INT3=1 LEONIDA_TITLE_WINDOWS_MB=1024 LEONIDA_MAP_READBACK=1, LEONIDA_PIPELINE_CACHE_DIR pointing at the offline cache. Host image copy: off (auto: NVIDIA) from #1851. One run per row.

run 1 run 2 (+ LEONIDA_TITLE_WATCHDOG=0)
end 344 s: the title's hang watchdog (null write at game_scarlett_master.exe+0x23cf683) full 484 s, stopped by the script
device loss / fault report none none
D3D12 calls 330,487 375,686
ExecuteCommandLists 5,490 6,017
Dispatch / DrawIndexedInstanced 2,435 / 2,726 2,779 / 6,026
PresentX 1,358 ok, 0 failed 1,465 ok, 0 failed
captures 23, all non-black 25, all non-black
indirect draws recorded / emitted / skipped 64 / 0 / 5,092 128 / 34 / 9,244 (#429 not included)
  • WRITE_INVALID: the world-start WRITE_INVALID did not happen in either run. On this machine it ended an earlier run with host image copies on (main 42537e7b6 + #1631; my run table of 07:54 in #1608).
  • #1950 / #1886: in run 1 the exit filter ran on the title's fatal exception: "1 pipeline build(s) still running at exit; writing the pipelines finished so far". It then refused the write: "pipeline cache is 9722912321 bytes, over the 4294967296-byte write limit". With a seeded offline cache, the union is past 4 GiB, so nothing from the session was kept. This is the seeded case raised on #1886. No session file was written in either run.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7170582625 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1894#issuecomment-7170582625). Originally posted by [Tyrannys](https://github.com/Tyrannys) on 2026-11-25T18:12:08Z. --- Test report from a combined build on a second NVIDIA machine. Counts only. **Machine:** Windows 11, RTX 4070 SUPER, NVIDIA 621.01, 64 GB, own 1.0.2.1 copy. **Build:** `main` `fe1553456` (already contains #1827 and #1893), plus #674, #1662, #1851, #1849, #1905, #1957, #1950, #1886 and #1894. All of them merged without conflicts. **Shaders:** translated on `3de22a190` + #674 + #1662 with `--wave64-emulate`. 29,279 of 29,280 translated, and all 29,279 pass `spirv-val`. That is 2,683 library programs and 29 of 29 FSPX. `main`'s translator changes since then are correctness fixes only. **Pipeline cache:** warm and complete, 26,503 of 26,503 (9.6 GB). - Three library compute programs took 30 to 32 minutes each to build alone: the ScreenProbes `ActivateRays`, `ActivateProbes` and `ActivateProbesTarget` programs of indirect diffuse lighting. - Building all three at once crashed the NVIDIA compiler ("NVVM compilation failed: 3", after 22 minutes). **Recipe:** `scripts/windows-boot/boot.ps1 -Seconds 480`, `LEONIDA_KEYBOARD_PAD=1 LEONIDA_SKIP_INT3=1 LEONIDA_TITLE_WINDOWS_MB=1024 LEONIDA_MAP_READBACK=1`, `LEONIDA_PIPELINE_CACHE_DIR` pointing at the offline cache. Host image copy: `off (auto: NVIDIA)` from #1851. One run per row. | | run 1 | run 2 (+ `LEONIDA_TITLE_WATCHDOG=0`) | |---|---|---| | end | 344 s: the title's hang watchdog (null write at `game_scarlett_master.exe+0x23cf683`) | full 484 s, stopped by the script | | device loss / fault report | none | none | | D3D12 calls | 330,487 | 375,686 | | ExecuteCommandLists | 5,490 | 6,017 | | Dispatch / DrawIndexedInstanced | 2,435 / 2,726 | 2,779 / 6,026 | | PresentX | 1,358 ok, 0 failed | 1,465 ok, 0 failed | | captures | 23, all non-black | 25, all non-black | | indirect draws recorded / emitted / skipped | 64 / 0 / 5,092 | 128 / 34 / 9,244 (#429 not included) | - **WRITE_INVALID:** the world-start WRITE_INVALID did not happen in either run. On this machine it ended an earlier run with host image copies on (`main` `42537e7b6` + #1631; my run table of 07:54 in #1608). - **#1950 / #1886:** in run 1 the exit filter ran on the title's fatal exception: "1 pipeline build(s) still running at exit; writing the pipelines finished so far". It then refused the write: "pipeline cache is 9722912321 bytes, over the 4294967296-byte write limit". With a seeded offline cache, the union is past 4 GiB, so nothing from the session was kept. This is the seeded case raised on #1886. No session file was written in either run. AI-assisted (Claude Code).
ecox982745 commented 2026-11-25 18:46:39 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ecox982745 on 2026-11-25T18:46:39Z.


Updated for 06ba2eb2d (Pascal memory-type fix). I rebuilt this head with #2020 e500e9949. There is still one conflict in Resource::create_texture. Keep #1894's side of the conflicting hunk and use const bool can_stage = can_stage_title && (!shared_zero_ || no_host_copy);. All three existing-heap CTests passed on the RTX 4090 with Vulkan validation enabled, including the new zero-memory-type R8 fixture and #2020's shared BC placement checks.

I tested this PR (14f04ce2d) together with DadaCap's #2020 (e500e9949) on an RTX 4090, Windows 11, NVIDIA 616.64. The two heads have one merge conflict, in Resource::create_texture. Git merged the documentation and test changes cleanly.

For whoever rebases the second PR, the resolution I tested was to keep #1894's side of the conflicting hunk and replace !shared_zero_ in can_stage with (!shared_zero_ || no_host_copy). The resulting declaration is:

const bool can_stage = stage_title && allow_staged_title && (!shared_zero_ || no_host_copy) && cpu_copyable &&
                       origin != TitleImageOrigin::ordinary && format.aspects == VK_IMAGE_ASPECT_COLOR_BIT;

This keeps #2020's shared zero image eligible for a later staged upload when host image copies are disabled. It also keeps #1894's fallback when the device supports host image copies but the particular texture cannot use them. The rest of the source merged automatically.

All three existing-heap CTests passed on that resolution (default, write watch off, write watch on). They exercised the R8 format restriction, the BC1 image-usage restriction, and the device-wide host-copy-off case. With deferral enabled, the compressed placements shared the initial image and retained all 512 checked bytes after a CPU write and GPU copy. With LEONIDA_PLACED_IMAGE_DEFER=0, the default CTest also passed and reported eager allocation with the same 512 bytes intact. These are synthetic GPU readbacks. AI-assisted verification with OpenAI Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7171384333 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1894#issuecomment-7171384333). Originally posted by [ecox982745](https://github.com/ecox982745) on 2026-11-25T18:46:39Z. --- **Updated for `06ba2eb2d` (Pascal memory-type fix).** I rebuilt this head with #2020 `e500e9949`. There is still one conflict in `Resource::create_texture`. Keep #1894's side of the conflicting hunk and use `const bool can_stage = can_stage_title && (!shared_zero_ || no_host_copy);`. All three existing-heap CTests passed on the RTX 4090 with Vulkan validation enabled, including the new zero-memory-type R8 fixture and #2020's shared BC placement checks. I tested this PR (`14f04ce2d`) together with DadaCap's #2020 (`e500e9949`) on an RTX 4090, Windows 11, NVIDIA 616.64. The two heads have **one merge conflict**, in `Resource::create_texture`. Git merged the documentation and test changes cleanly. For whoever rebases the second PR, the resolution I tested was to keep #1894's side of the conflicting hunk and replace `!shared_zero_` in `can_stage` with `(!shared_zero_ || no_host_copy)`. The resulting declaration is: ```cpp const bool can_stage = stage_title && allow_staged_title && (!shared_zero_ || no_host_copy) && cpu_copyable && origin != TitleImageOrigin::ordinary && format.aspects == VK_IMAGE_ASPECT_COLOR_BIT; ``` This keeps #2020's shared zero image eligible for a later staged upload when host image copies are disabled. It also keeps #1894's fallback when the device supports host image copies but the particular texture cannot use them. The rest of the source merged automatically. All three existing-heap CTests passed on that resolution (default, write watch off, write watch on). They exercised the R8 format restriction, the BC1 image-usage restriction, and the device-wide host-copy-off case. With deferral enabled, the compressed placements shared the initial image and retained all 512 checked bytes after a CPU write and GPU copy. With `LEONIDA_PLACED_IMAGE_DEFER=0`, the default CTest also passed and reported eager allocation with the same 512 bytes intact. These are synthetic GPU readbacks. AI-assisted verification with OpenAI Codex.
qhukz13 commented 2026-11-25 19:57:33 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by qhukz13 on 2026-11-25T19:57:33Z.


Ran this on a GPU where the driver itself takes host image copy for the format but gives the HOST_TRANSFER image no memory type: Windows 10 Pro 19045, GeForce GTX 1050 Ti (Pascal, 4 GB, no Resizable BAR), NVIDIA 582.66, MSVC RelWithDebInfo. Base main 9f9a7c5f3, with and without this PR (14f04ce2d, merged cleanly), d3d12_existing_heap* 3x each, plain and with LEONIDA_VK_VALIDATION=1.

Result is the same on both sides: d3d12_existing_heap, _no_write_watch and _write_watch fail, d3d12_host_prefix passes, no validation messages. The failure is the persistent slot-133 plane on the real (unmasked) device:

[rt] d3d12: texture memory unavailable: 2048 bytes, alignment 1024, type bits 0x0 (vk format 9 256x8)
persistent slot-133 plane line 1395: std::all_of(pixels.begin(), pixels.end(), [&](auto value) { return value == 61 * pass; })

The PR's own masked-R8 device and the host_image_copy = false device pass the same check here, so the new path works; it is just not taken for this case. Reading Resource::create_texture at 14f04ce2d: for a placed LINEAR title image whose format does take host transfer, host_transfer_ stays true, so needs_staging is false; the placement heuristic is skipped by !linear_placement; the image is created with HOST_TRANSFER; bind_texture_memory gets memoryTypeBits == 0; and can_retry_host is false, so create_texture returns E_OUTOFMEMORY. The recreate-without-HOST_TRANSFER fallback from #1364 lives only in the origin == ordinary branch, so it never runs for title images.

This predates the PR, but the PR is the natural place for it: treat "HOST_TRANSFER leaves no memory type" like "the format refuses host transfer". For example, when can_stage && host_transfer_, check device_.memory_requirements(info, with) up front and, if with.memoryTypeBits == 0, drop VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT, set host_transfer_ = false and take the needs_staging branch (any compatible type). This is the case Pascal hits for a movie plane, which is on the boot path. Happy to rerun a fix here.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7172992761 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1894#issuecomment-7172992761). Originally posted by [qhukz13](https://github.com/qhukz13) on 2026-11-25T19:57:33Z. --- Ran this on a GPU where the driver itself takes host image copy for the format but gives the HOST_TRANSFER image no memory type: Windows 10 Pro 19045, GeForce GTX 1050 Ti (Pascal, 4 GB, no Resizable BAR), NVIDIA 582.66, MSVC RelWithDebInfo. Base main `9f9a7c5f3`, with and without this PR (`14f04ce2d`, merged cleanly), `d3d12_existing_heap*` 3x each, plain and with `LEONIDA_VK_VALIDATION=1`. Result is the same on both sides: `d3d12_existing_heap`, `_no_write_watch` and `_write_watch` fail, `d3d12_host_prefix` passes, no validation messages. The failure is the persistent slot-133 plane on the real (unmasked) device: ``` [rt] d3d12: texture memory unavailable: 2048 bytes, alignment 1024, type bits 0x0 (vk format 9 256x8) persistent slot-133 plane line 1395: std::all_of(pixels.begin(), pixels.end(), [&](auto value) { return value == 61 * pass; }) ``` The PR's own masked-R8 device and the `host_image_copy = false` device pass the same check here, so the new path works; it is just not taken for this case. Reading `Resource::create_texture` at `14f04ce2d`: for a placed LINEAR title image whose format does take host transfer, `host_transfer_` stays true, so `needs_staging` is false; the placement heuristic is skipped by `!linear_placement`; the image is created with HOST_TRANSFER; `bind_texture_memory` gets `memoryTypeBits == 0`; and `can_retry_host` is false, so `create_texture` returns `E_OUTOFMEMORY`. The recreate-without-HOST_TRANSFER fallback from #1364 lives only in the `origin == ordinary` branch, so it never runs for title images. This predates the PR, but the PR is the natural place for it: treat "HOST_TRANSFER leaves no memory type" like "the format refuses host transfer". For example, when `can_stage && host_transfer_`, check `device_.memory_requirements(info, with)` up front and, if `with.memoryTypeBits == 0`, drop `VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT`, set `host_transfer_ = false` and take the `needs_staging` branch (any compatible type). This is the case Pascal hits for a movie plane, which is on the boot path. Happy to rerun a fix here. AI-assisted (Claude Code).
ecox982745 commented 2026-11-25 20:22:19 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ecox982745 on 2026-11-25T20:22:19Z.


@qhukz13, could you rerun d3d12_existing_heap, d3d12_existing_heap_no_write_watch and d3d12_existing_heap_write_watch on the GTX 1050 Ti at 06ba2eb2d? Your unmasked device is the check that matters here.

The runtime now checks which memory types the host-transfer image can bind before choosing its backing. If the driver returns zero types, a CPU-fillable colour title image takes the staged upload path. This includes the mapped linear R8 plane from your report.

On the RTX 4090 (Windows 11, NVIDIA 616.64), a Vulkan test shim made only the 256×8 R8 host-transfer image report zero memory types. The previous PR head reproduced your 2,048-byte allocation failure and failed the pixel check. At the new head, all three CTests passed with validation off and all three passed with VK_LAYER_KHRONOS_validation enabled. The original format and usage restrictions are also covered in those runs. All inputs were synthetic.

AI-assisted with OpenAI Codex (gpt-6.2-astra).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7173571345 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1894#issuecomment-7173571345). Originally posted by [ecox982745](https://github.com/ecox982745) on 2026-11-25T20:22:19Z. --- @qhukz13, could you rerun `d3d12_existing_heap`, `d3d12_existing_heap_no_write_watch` and `d3d12_existing_heap_write_watch` on the GTX 1050 Ti at `06ba2eb2d`? Your unmasked device is the check that matters here. The runtime now checks which memory types the host-transfer image can bind before choosing its backing. If the driver returns zero types, a CPU-fillable colour title image takes the staged upload path. This includes the mapped linear R8 plane from your report. On the RTX 4090 (Windows 11, NVIDIA 616.64), a Vulkan test shim made only the 256×8 R8 host-transfer image report zero memory types. The previous PR head reproduced your 2,048-byte allocation failure and failed the pixel check. At the new head, all three CTests passed with validation off and all three passed with `VK_LAYER_KHRONOS_validation` enabled. The original format and usage restrictions are also covered in those runs. All inputs were synthetic. AI-assisted with OpenAI Codex (`gpt-6.2-astra`).
qhukz13 commented 2026-11-25 21:01:54 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by qhukz13 on 2026-11-25T21:01:54Z.


Rerun at 06ba2eb2d on the GTX 1050 Ti (Windows 10 Pro 19045, NVIDIA 582.66, MSVC RelWithDebInfo), merged onto main 9f9a7c5f3, 3 runs each, plain and with LEONIDA_VK_VALIDATION=1:

test 14f04ce2d 06ba2eb2d
d3d12_existing_heap fails (texture memory unavailable: 2048 bytes ... type bits 0x0 (vk format 9 256x8), plane check at line 1395) passes 3/3, 3/3
d3d12_existing_heap_no_write_watch fails, same passes 3/3, 3/3
d3d12_existing_heap_write_watch fails, same passes 3/3, 3/3
d3d12_host_prefix, d3d12_subresource_copy pass pass 3/3, 3/3

No validation messages. So the real unmasked device is fixed, thanks.

One more data point for the docs or the comment: on this driver it is not only the R8 plane. A variant of the same check that logs (a local commit of mine on top of 14f04ce2d, same tests) took that branch for title images of vk format 9 (R8_UNORM), 37 (R8G8B8A8_UNORM) and 133 (BC1_RGBA_UNORM_BLOCK), so "Pascal gives a HOST_TRANSFER image no memory type" is the general case here, not an R8 quirk. Your head does not log that branch, so I could not count it there; a log_once on it would make the next report easier.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7174515492 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1894#issuecomment-7174515492). Originally posted by [qhukz13](https://github.com/qhukz13) on 2026-11-25T21:01:54Z. --- Rerun at `06ba2eb2d` on the GTX 1050 Ti (Windows 10 Pro 19045, NVIDIA 582.66, MSVC RelWithDebInfo), merged onto main `9f9a7c5f3`, 3 runs each, plain and with `LEONIDA_VK_VALIDATION=1`: | test | `14f04ce2d` | `06ba2eb2d` | |---|---|---| | `d3d12_existing_heap` | fails (`texture memory unavailable: 2048 bytes ... type bits 0x0 (vk format 9 256x8)`, plane check at line 1395) | passes 3/3, 3/3 | | `d3d12_existing_heap_no_write_watch` | fails, same | passes 3/3, 3/3 | | `d3d12_existing_heap_write_watch` | fails, same | passes 3/3, 3/3 | | `d3d12_host_prefix`, `d3d12_subresource_copy` | pass | pass 3/3, 3/3 | No validation messages. So the real unmasked device is fixed, thanks. One more data point for the docs or the comment: on this driver it is not only the R8 plane. A variant of the same check that logs (a local commit of mine on top of `14f04ce2d`, same tests) took that branch for title images of `vk format 9` (R8_UNORM), `37` (R8G8B8A8_UNORM) and `133` (BC1_RGBA_UNORM_BLOCK), so "Pascal gives a HOST_TRANSFER image no memory type" is the general case here, not an R8 quirk. Your head does not log that branch, so I could not count it there; a `log_once` on it would make the next report easier. AI-assisted (Claude Code).
qhukz13 commented 2026-11-26 19:05:05 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by qhukz13 on 2026-11-26T19:05:05Z.


One more data point for this PR, from a full ctest baseline on Pascal. On current main the title-placed texture tests fail, and with this PR they pass. GTX 1050 Ti, NVIDIA 582.66, Windows 10, both sides built from main e57bc63bc, the PR merged in cleanly:

test main main + this PR (2d258c8cd)
d3d12_existing_heap fails: persistent slot-133 plane, line 1530 (pixels not 61 * pass) passes
d3d12_existing_heap_no_write_watch fails, same line passes
d3d12_existing_heap_write_watch fails, same line passes
d3d12_mapped_plane_async fails: first use line 1584: filled passes
d3d12_vulkan_device fails, line 7362: heap_mismatches <= 0 fails the same way (separate issue)

On main the log shows slot 133 texture not created (hr 0x80070057, layout 6): dim 3 format 28 64x64x1 mips 12: an R8G8B8A8 texture the title places in its own memory is refused on this card, the HOST_TRANSFER case this PR handles. So the PR matters on Pascal for title-placed textures on that path in general, not only for the movie plane. The d3d12_vulkan_device failure is unrelated: it fails identically on both sides.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7201177728 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1894#issuecomment-7201177728). Originally posted by [qhukz13](https://github.com/qhukz13) on 2026-11-26T19:05:05Z. --- One more data point for this PR, from a full `ctest` baseline on Pascal. On current main the title-placed texture tests fail, and with this PR they pass. GTX 1050 Ti, NVIDIA 582.66, Windows 10, both sides built from main `e57bc63bc`, the PR merged in cleanly: | test | main | main + this PR (`2d258c8cd`) | |---|---|---| | `d3d12_existing_heap` | **fails**: persistent slot-133 plane, `line 1530` (pixels not `61 * pass`) | passes | | `d3d12_existing_heap_no_write_watch` | fails, same line | passes | | `d3d12_existing_heap_write_watch` | fails, same line | passes | | `d3d12_mapped_plane_async` | fails: `first use line 1584: filled` | passes | | `d3d12_vulkan_device` | fails, `line 7362: heap_mismatches <= 0` | fails the same way (separate issue) | On main the log shows `slot 133 texture not created (hr 0x80070057, layout 6): dim 3 format 28 64x64x1 mips 12`: an R8G8B8A8 texture the title places in its own memory is refused on this card, the HOST_TRANSFER case this PR handles. So the PR matters on Pascal for title-placed textures on that path in general, not only for the movie plane. The `d3d12_vulkan_device` failure is unrelated: it fails identically on both sides. AI-assisted (Claude Code).
robot00f commented 2026-11-27 05:57:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by robot00f on 2026-11-27T05:57:29Z.


Independent check on real Pascal hardware of head 2d258c8c, for the case @qhukz13 reported on 14f04ce2d (that commit predates the memory-type fix, so it could not have covered it).

Machine: Windows 10 Pro 22H2 (19045), Intel Core i7-2600, 4 GB GeForce GTX 1050 Ti, NVIDIA 582.28, MSVC 19.44 RelWithDebInfo.

Setup: main d1dff794, with only the two runtime files of this PR applied (clean 3-way apply; no commit, nothing pushed). The test binary was rebuilt from both trees with the same build directory.

Before (main d1dff794): d3d12_existing_heap failed 3 of 3 runs, exit 1, at the persistent slot-133 plane check (std::all_of(pixels..., value == 61 * pass)), with this line twice per run:

[rt] d3d12: texture memory unavailable: 2048 bytes, alignment 1024, type bits 0x0 (vk format 9 256x8)

That is the real driver's memoryTypeBits == 0 for the 256x8 R8 plane, not the test shim, and it lands on the title-image branch (d3d12_vulkan_device.cpp, the origin != TitleImageOrigin::ordinary path) that had no recreate-without-host-transfer step.

After (2d258c8c): the same test passed 3 of 3 runs, exit 0, and the new line appeared 3 times per run:

[rt] d3d12: title image has no host-transfer memory type, using staging for Vulkan format ...

ctest -R "^d3d12_existing_heap" then reported 3 of 3 passed (the default, _no_write_watch and _write_watch entries). I stopped the repeated CTest iterations there, so the three CTest entries have one full pass each rather than three.

Not covered by this check: validation layers were not enabled, other tests were not run, and only the memory-type branch above was exercised (the shim-forced paths were left alone).

AI-assisted (OpenCode, DeepSeek).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7211090914 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1894#issuecomment-7211090914). Originally posted by [robot00f](https://github.com/robot00f) on 2026-11-27T05:57:29Z. --- Independent check on real Pascal hardware of head `2d258c8c`, for the case @qhukz13 reported on `14f04ce2d` (that commit predates the memory-type fix, so it could not have covered it). **Machine:** Windows 10 Pro 22H2 (19045), Intel Core i7-2600, 4 GB GeForce GTX 1050 Ti, NVIDIA 582.28, MSVC 19.44 RelWithDebInfo. **Setup:** `main` `d1dff794`, with only the two runtime files of this PR applied (clean 3-way apply; no commit, nothing pushed). The test binary was rebuilt from both trees with the same build directory. **Before (`main` `d1dff794`):** `d3d12_existing_heap` failed 3 of 3 runs, exit 1, at the persistent slot-133 plane check (`std::all_of(pixels..., value == 61 * pass)`), with this line twice per run: ``` [rt] d3d12: texture memory unavailable: 2048 bytes, alignment 1024, type bits 0x0 (vk format 9 256x8) ``` That is the real driver's `memoryTypeBits == 0` for the 256x8 R8 plane, not the test shim, and it lands on the title-image branch (`d3d12_vulkan_device.cpp`, the `origin != TitleImageOrigin::ordinary` path) that had no recreate-without-host-transfer step. **After (`2d258c8c`):** the same test passed 3 of 3 runs, exit 0, and the new line appeared 3 times per run: ``` [rt] d3d12: title image has no host-transfer memory type, using staging for Vulkan format ... ``` `ctest -R "^d3d12_existing_heap"` then reported 3 of 3 passed (the default, `_no_write_watch` and `_write_watch` entries). I stopped the repeated CTest iterations there, so the three CTest entries have one full pass each rather than three. **Not covered by this check:** validation layers were not enabled, other tests were not run, and only the memory-type branch above was exercised (the shim-forced paths were left alone). AI-assisted (OpenCode, DeepSeek).
ecox982745 commented 2026-11-28 03:03:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ecox982745 on 2026-11-28T03:03:42Z.


I resolved the staging conflict locally using PR head 2d258c8cd and main 02f71ccfe. Only runtime/shims/d3d12_vulkan_device.cpp conflicted. In the single conflict block, keep the PR's needs_staging branch and change the first line of that block to:

const bool can_stage = can_stage_title && (!shared_zero_ || no_host_copy);

I also simplified the existing no_host_copy predicate to !device_.copy_memory_to_image && cpu_copyable. This preserves main's shared-zero BC texture path when the device has no host image copy, alongside the PR's per-format fallback.

RTX 4090, Windows 11, NVIDIA 616.64, Vulkan validation enabled. I ran the same synthetic texture checks on each tree, using a local driver restricted to the texture portion of the existing-heap fixture. The default, write-watch-on and write-watch-off runs all failed on main and all passed with the resolution. Shared BC1 placements preserved all 512 bytes after a CPU write and GPU copy with host image copies both enabled and disabled. The stock d3d12_mapped_plane_async CTest also passed on the resolved tree. Both trees emitted the same device-destruction validation diagnostic (VUID-vkDestroyDevice-device-05137) during the focused runs.

The public branch still needs the merge. GitHub declined the push because main brings CI workflow updates that the connected account lacks permission to publish. AI-assisted resolution and hardware verification using OpenAI Codex (GPT-6).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232768273 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1894#issuecomment-7232768273). Originally posted by [ecox982745](https://github.com/ecox982745) on 2026-11-28T03:03:42Z. --- I resolved the staging conflict locally using PR head `2d258c8cd` and main `02f71ccfe`. Only `runtime/shims/d3d12_vulkan_device.cpp` conflicted. In the single conflict block, keep the PR's `needs_staging` branch and change the first line of that block to: ```cpp const bool can_stage = can_stage_title && (!shared_zero_ || no_host_copy); ``` I also simplified the existing `no_host_copy` predicate to `!device_.copy_memory_to_image && cpu_copyable`. This preserves main's shared-zero BC texture path when the device has no host image copy, alongside the PR's per-format fallback. **RTX 4090, Windows 11, NVIDIA 616.64, Vulkan validation enabled.** I ran the same synthetic texture checks on each tree, using a local driver restricted to the texture portion of the existing-heap fixture. The default, write-watch-on and write-watch-off runs all failed on main and all passed with the resolution. Shared BC1 placements preserved all 512 bytes after a CPU write and GPU copy with host image copies both enabled and disabled. The stock `d3d12_mapped_plane_async` CTest also passed on the resolved tree. Both trees emitted the same device-destruction validation diagnostic (`VUID-vkDestroyDevice-device-05137`) during the focused runs. The public branch still needs the merge. GitHub declined the push because main brings CI workflow updates that the connected account lacks permission to publish. AI-assisted resolution and hardware verification using OpenAI Codex (GPT-6).
ecox982745 commented 2026-11-28 04:03:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ecox982745 on 2026-11-28T04:03:29Z.


The conflict resolution is on the public branch at 5c815be84b. I merged the upstream shared-BC change (e500e99494) into this PR. GitHub reports a clean merge. Its test merge 438a5609eb has parents f77359c5b4 (main) and 5c815be84b (this PR), and tree b0d1bd5d66, identical to the tree I tested. The PR file list still uses an older base. The comparison against the tested main shows the three affected files. Three-file comparison

Windows 11, RTX 4090, NVIDIA 616.64, Vulkan validation enabled. I ran the synthetic texture portion of the existing-heap fixture in the default, write-watch-on and write-watch-off configurations. All three failed on plain f77359c5b4 with the PR's fixture (R8 plane and BC1 array readbacks). All three passed on the PR head and on the test merge. The stock d3d12_mapped_plane_async CTest also passed on the test merge. Main and the test merge both emitted VUID-vkDestroyDevice-device-05137 at device teardown during the focused runs.

AI-assisted integration and hardware verification using OpenAI Codex (GPT-6).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7233641217 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1894#issuecomment-7233641217). Originally posted by [ecox982745](https://github.com/ecox982745) on 2026-11-28T04:03:29Z. --- The conflict resolution is on the public branch at `5c815be84b`. I merged the upstream shared-BC change (`e500e99494`) into this PR. GitHub reports a clean merge. Its test merge `438a5609eb` has parents `f77359c5b4` (main) and `5c815be84b` (this PR), and tree `b0d1bd5d66`, identical to the tree I tested. The PR file list still uses an older base. The comparison against the tested main shows the three affected files. [Three-file comparison](https://github.com/ProjectLeonida/mandy/compare/f77359c5b42fdba8025bf4bf6cf553a945a8451b...5c815be84bfe31b5c8a8bc104ce8c93962a5571b) **Windows 11, RTX 4090, NVIDIA 616.64, Vulkan validation enabled.** I ran the synthetic texture portion of the existing-heap fixture in the default, write-watch-on and write-watch-off configurations. All three failed on plain `f77359c5b4` with the PR's fixture (R8 plane and BC1 array readbacks). All three passed on the PR head and on the test merge. The stock `d3d12_mapped_plane_async` CTest also passed on the test merge. Main and the test merge both emitted `VUID-vkDestroyDevice-device-05137` at device teardown during the focused runs. AI-assisted integration and hardware verification using OpenAI Codex (GPT-6).
zmasi commented 2026-11-29 02:36:05 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-29T02:36:05Z.


Independent Hardware Verification (RTX 3090, Windows 11, VK_LAYER_KHRONOS_validation 1.4.363.1)

  • Tested merge: origin/main (04f484006e) + PR #1894 (5c815be84b) — clean 3-way merge (0 conflicts, confirming the shared_zero_ integration const bool can_stage = can_stage_title && (!shared_zero_ || no_host_copy); in Resource::create_texture).
  • Environment: NVIDIA GeForce RTX 3090 (24 GB, Resizable BAR), Windows 11, Visual Studio 2022 (MSVC 19.44 RelWithDebInfo), Vulkan SDK + VK_LAYER_KHRONOS_validation 1.4.363.1 (LEONIDA_VK_VALIDATION=1).

Red -> Green Results

  1. Red (d3d12_existing_heap built against origin/main's runtime/shims/d3d12_vulkan_device.cpp):
    • Failed as expected (rc=8, 9.40 s) when exercising the R8 format-feature mask, BC1 host-transfer usage rejection, and zero-memoryTypeBits 256x8 R8 movie-plane shims.
  2. Green (origin/main 04f484006e + #1894 5c815be84b, LEONIDA_VK_VALIDATION=1):
    • 4/4 CTests passed (27.10 s total):
      • d3d12_existing_heap: Passed (shared BC1 placements, mapped R8 plane, mapped BC1 array, per-format R8/BC1 fallback, zero-memoryTypeBits R8 plane fallback, and host_image_copy = false controls all matched)
      • d3d12_mapped_plane_async: Passed
      • d3d12_existing_heap_no_write_watch: Passed
      • d3d12_existing_heap_write_watch: Passed (9.51 s)
    • Validation diagnostics: zero new VUIDs introduced (only the pre-existing VUID-vkDestroyDevice-device-05137 teardown message present identically on origin/main).
    • python -m unittest tests/test_docs_encoding.py tests/test_docs_repo_paths.py: 6/6 passed.
    • python -I scripts/check_no_game_data.py docs/d3d12_vulkan.md runtime/shims/d3d12_vulkan_device.cpp runtime/test/d3d12_existing_heap_test.cpp: passed (0 issues). No game files used.

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7249530005 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1894#issuecomment-7249530005). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-29T02:36:05Z. --- ### Independent Hardware Verification (RTX 3090, Windows 11, `VK_LAYER_KHRONOS_validation` `1.4.363.1`) - **Tested merge:** `origin/main` (`04f484006e`) + PR `#1894` (`5c815be84b`) — clean 3-way merge (`0` conflicts, confirming the `shared_zero_` integration `const bool can_stage = can_stage_title && (!shared_zero_ || no_host_copy);` in `Resource::create_texture`). - **Environment:** NVIDIA GeForce RTX 3090 (24 GB, Resizable BAR), Windows 11, Visual Studio 2022 (MSVC 19.44 `RelWithDebInfo`), Vulkan SDK + `VK_LAYER_KHRONOS_validation` `1.4.363.1` (`LEONIDA_VK_VALIDATION=1`). #### Red -> Green Results 1. **Red (`d3d12_existing_heap` built against `origin/main`'s `runtime/shims/d3d12_vulkan_device.cpp`):** - Failed as expected (`rc=8`, `9.40 s`) when exercising the R8 format-feature mask, BC1 host-transfer usage rejection, and zero-`memoryTypeBits` 256x8 R8 movie-plane shims. 2. **Green (`origin/main` `04f484006e` + `#1894` `5c815be84b`, `LEONIDA_VK_VALIDATION=1`):** - **4/4 CTests passed** (`27.10 s` total): - `d3d12_existing_heap`: Passed (shared BC1 placements, mapped R8 plane, mapped BC1 array, per-format R8/BC1 fallback, zero-`memoryTypeBits` R8 plane fallback, and `host_image_copy = false` controls all matched) - `d3d12_mapped_plane_async`: Passed - `d3d12_existing_heap_no_write_watch`: Passed - `d3d12_existing_heap_write_watch`: Passed (`9.51 s`) - Validation diagnostics: zero new VUIDs introduced (only the pre-existing `VUID-vkDestroyDevice-device-05137` teardown message present identically on `origin/main`). - `python -m unittest tests/test_docs_encoding.py tests/test_docs_repo_paths.py`: `6/6` passed. - `python -I scripts/check_no_game_data.py docs/d3d12_vulkan.md runtime/shims/d3d12_vulkan_device.cpp runtime/test/d3d12_existing_heap_test.cpp`: passed (`0` issues). No game files used. AI-assisted: yes
OreoFR commented 2026-11-29 05:47:48 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T05:47:48Z.


Verified by OreoFR — READY

  • Base: main c8bf0e7b6 + this PR (head 5c815be84) merged with --no-ff
  • Red (main + only this PR's tests): d3d12_existing_heap, _no_write_watch and _write_watch all fail on main with the PR's new cases (slot 133 texture not created (hr 0x80070057) for a format-28 texture with no host copy).
  • Green (merge): all three pass; ctest (Ninja RelWithDebInfo, all targets, gta6rt launchers excluded) in package p2 = main + #1874 + #1894 + #1713 (no shared files): 495 tests, new failures vs main: none (main alone: 494 tests, 5 failures: loader, xs_proxy_mock, xmem_no_write_watch, api_ref_state timeout, xbox_present; xbox_present fails in every package as on main). Translator suite on this merge: the same as main (the translator part of this PR is already on main)
  • gta6rt.exe links without the XMA decoder (LEONIDA_CARGO=OFF, LEONIDA_XMA2_DECODER_LIB empty), main + this PR alone; imports unchanged vs main (25 DLLs, 655 functions, no WS2_32)
  • Diff read: no issue. The staging path is taken when HOST_TRANSFER is missing or has no memory type, and the retry is still limited to !needs_staging.
  • Other runs: Consistent with zmasi's run.
  • Machine: Windows 11, Intel Core Ultra 7 155H, RTX 4070 Laptop 8 GB, NVIDIA 621.40, Python 3.12.10, MSVC 19.44

AI-assisted (Claude Code, Claude Opus 5.5), run for OreoFR.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7251464849 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1894#issuecomment-7251464849). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T05:47:48Z. --- **Verified by OreoFR** — READY - Base: main c8bf0e7b6 + this PR (head 5c815be84) merged with --no-ff - Red (main + only this PR's tests): `d3d12_existing_heap`, `_no_write_watch` and `_write_watch` all fail on main with the PR's new cases (`slot 133 texture not created (hr 0x80070057)` for a format-28 texture with no host copy). - Green (merge): all three pass; ctest (Ninja RelWithDebInfo, all targets, gta6rt launchers excluded) in package p2 = main + #1874 + #1894 + #1713 (no shared files): 495 tests, new failures vs main: none (main alone: 494 tests, 5 failures: loader, xs_proxy_mock, xmem_no_write_watch, api_ref_state timeout, xbox_present; xbox_present fails in every package as on main). Translator suite on this merge: the same as main (the translator part of this PR is already on main) - gta6rt.exe links without the XMA decoder (`LEONIDA_CARGO=OFF`, `LEONIDA_XMA2_DECODER_LIB` empty), main + this PR alone; imports unchanged vs main (25 DLLs, 655 functions, no WS2_32) - Diff read: no issue. The staging path is taken when HOST_TRANSFER is missing or has no memory type, and the retry is still limited to `!needs_staging`. - Other runs: Consistent with zmasi's run. - Machine: Windows 11, Intel Core Ultra 7 155H, RTX 4070 Laptop 8 GB, NVIDIA 621.40, Python 3.12.10, MSVC 19.44 AI-assisted (Claude Code, Claude Opus 5.5), run for OreoFR.
MoonEyes commented 2026-11-29 15:43:17 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T15:43:17Z.


Merged. Tested by @OreoFR on head 5c815be84 (RTX 4070 Laptop 8 GB, Windows 11): red: d3d12_existing_heap(+_no_write_watch,_write_watch) fail on main (slot 133 texture not created); green pass. Correction: no CI check run or commit status exists for this head, so CI did not validate it. My earlier sentence about red jobs was wrong. Thanks @ecox982745!

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7258313220 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1894#issuecomment-7258313220). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T15:43:17Z. --- Merged. Tested by @OreoFR on head 5c815be84 (RTX 4070 Laptop 8 GB, Windows 11): red: d3d12_existing_heap(+_no_write_watch,_write_watch) fail on main (slot 133 texture not created); green pass. Correction: no CI check run or commit status exists for this head, so CI did not validate it. My earlier sentence about red jobs was wrong. Thanks @ecox982745! AI-assisted: yes
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!1894
No description provided.