d3d12: a placed BC image the title has not filled shares a zero image without host copies too (RT-PLACED-DEFER-STAGED) #2020

Open
github-bot wants to merge 2 commits from github-bot/gh-2020 into main AGit
Owner

@⁠DadaCap on GitHub · 2026-11-25 18:16 UTC · original
DadaCap:placed-defer-no-host-copy → main · +23 −11 · 3 files · 2 commits · open

RT-PLACED-DEFER-STAGED, claimed in #1608. Follow-up of #1827 (mine).

What

With host image copies, a CPU-fillable, typed BC texture the title places (device slot 133) samples a shared zero image until a CPU write or GPU command gives it a backing. Without host copies (a device without VK_EXT_host_image_copy, or #1851's switch) create_texture never took that path, so each such image was backed when it was made. This lets it take the same path: the staged upload #1827 added fills the private image, and the first shader submission clears what nothing has filled. The shared zero image, which host copies fill, is cleared the same way there. Devices with host copies are unchanged. Other formats and typeless images stay eager, and the zero-image cache keeps its 256 MiB limit.

Measured

RTX 5080 16 GB, NVIDIA 621.24, Windows 11, host copies off, the memory probe (LEONIDA_MEM_PROBE=10) in the world phase of a tree with other open pull requests merged; one run each:

before with this
slot-133 "CPU-fillable without a fill" 3,952.8 MiB (t=240 s) 62.7 MiB (t=1,554 s)
device-local images (memory type 1) 10,470 MiB 6,791 MiB

Limits of that comparison: the two runs are at different points, and the second tree also had texture eviction, memory priorities and #1896. The first row is what this change acts on; I do not claim the whole second row for it. World frames also got faster (about 55 to 63 s to about 13 s with a diagnostic dump on in both), which I can't attribute to this change alone.

Tests

On this commit, RTX 5080, VS 18 RelWithDebInfo: d3d12_existing_heap, d3d12_xmem_placed, d3d12_m2_textured and d3d12_vulkan_device pass. d3d12_existing_heap now runs its shared-BC check on the device without host copies and requires the image to be unbound until its first use; it fails there without the shim change (checked by reverting it). No other GPU was used, and the whole ctest set was not run.

AI-assisted (Claude Code, Claude Opus 5.5).

🤖 Generated with Claude Code

**@⁠DadaCap** on GitHub · 2026-11-25 18:16 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2020) `DadaCap:placed-defer-no-host-copy` → `main` · +23 −11 · 3 files · 2 commits · open RT-PLACED-DEFER-STAGED, claimed in #1608. Follow-up of #1827 (mine). ## What With host image copies, a CPU-fillable, typed BC texture the title places (device slot 133) samples a shared zero image until a CPU write or GPU command gives it a backing. Without host copies (a device without `VK_EXT_host_image_copy`, or #1851's switch) `create_texture` never took that path, so each such image was backed when it was made. This lets it take the same path: the staged upload #1827 added fills the private image, and the first shader submission clears what nothing has filled. The shared zero image, which host copies fill, is cleared the same way there. Devices with host copies are unchanged. Other formats and typeless images stay eager, and the zero-image cache keeps its 256 MiB limit. ## Measured RTX 5080 16 GB, NVIDIA 621.24, Windows 11, host copies off, the memory probe (`LEONIDA_MEM_PROBE=10`) in the world phase of a tree with other open pull requests merged; one run each: | | before | with this | |---|---|---| | slot-133 "CPU-fillable without a fill" | 3,952.8 MiB (t=240 s) | 62.7 MiB (t=1,554 s) | | device-local images (memory type 1) | 10,470 MiB | 6,791 MiB | Limits of that comparison: the two runs are at different points, and the second tree also had texture eviction, memory priorities and #1896. The first row is what this change acts on; I do not claim the whole second row for it. World frames also got faster (about 55 to 63 s to about 13 s with a diagnostic dump on in both), which I can't attribute to this change alone. ## Tests On this commit, RTX 5080, VS 18 RelWithDebInfo: `d3d12_existing_heap`, `d3d12_xmem_placed`, `d3d12_m2_textured` and `d3d12_vulkan_device` pass. `d3d12_existing_heap` now runs its shared-BC check on the device without host copies and requires the image to be unbound until its first use; it fails there without the shim change (checked by reverting it). No other GPU was used, and the whole `ctest` set was not run. AI-assisted (Claude Code, Claude Opus 5.5). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:14:58 +00:00
Author
Owner

@⁠DadaCap on GitHub · 2026-11-27 02:23 UTC · original

Merged current main (d1dff7949) into the branch to clear the conflict in runtime/test/d3d12_existing_heap_test.cpp: both sides added a check on the staged (no host image copy) device, and both are kept. The five d3d12_existing_heap* tests pass on the RTX 5080 (NVIDIA 621.24). AI-assisted (Claude Code).

**@⁠DadaCap** on GitHub · 2026-11-27 02:23 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2020#issuecomment-7208081523) Merged current `main` (d1dff7949) into the branch to clear the conflict in `runtime/test/d3d12_existing_heap_test.cpp`: both sides added a check on the staged (no host image copy) device, and both are kept. The five `d3d12_existing_heap*` tests pass on the RTX 5080 (NVIDIA 621.24). AI-assisted (Claude Code).
Author
Owner

@⁠OreoFR on GitHub · 2026-11-27 03:05 UTC · original

Data from profile M (RTX 4070 Laptop 8 GB, NVIDIA 621.40), with this PR plus #1851 (LEONIDA_HOST_IMAGE_COPY=0) on main d1dff7949. The merge needed one trivial test resolution in d3d12_existing_heap_test.cpp: keep both checks.

LEONIDA_MEM_PROBE=10 at t=300 s, compared with an earlier run without this PR and with host copies on:

  • device-local images (type 1): 3,219 MiB, against 3,512;
  • texture blocks: 3,423 MiB, against 4,408;
  • render targets and depth: 2,171 MiB, against 4,164.

That's two variables at once (this PR and host copies off), and other settings differed (value-wait timeout, device type), so I don't claim the drop for this PR alone. MEASURED (n=1 each). Host-side commit went up: 37 GB private at peak. A 4 GB page file was not enough, 24 GB was. The run reached the world phase without a device loss, and the screen was black (pipelines async, see docs/running.md). AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠OreoFR** on GitHub · 2026-11-27 03:05 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2020#issuecomment-7208691360) Data from profile M (RTX 4070 Laptop 8 GB, NVIDIA 621.40), with this PR plus #1851 (`LEONIDA_HOST_IMAGE_COPY=0`) on `main` d1dff7949. The merge needed one trivial test resolution in `d3d12_existing_heap_test.cpp`: keep both checks. `LEONIDA_MEM_PROBE=10` at t=300 s, compared with an earlier run without this PR and with host copies on: - device-local images (type 1): 3,219 MiB, against 3,512; - texture blocks: 3,423 MiB, against 4,408; - render targets and depth: 2,171 MiB, against 4,164. That's two variables at once (this PR and host copies off), and other settings differed (value-wait timeout, device type), so I don't claim the drop for this PR alone. `MEASURED (n=1 each)`. Host-side commit went up: 37 GB private at peak. A 4 GB page file was not enough, 24 GB was. The run reached the world phase without a device loss, and the screen was black (pipelines async, see `docs/running.md`). AI-assisted (Claude Code, Claude Opus 5.5).
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2020/head:github-bot/gh-2020'
git switch 'github-bot/gh-2020'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2020'
git switch 'github-bot/gh-2020'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2020'
git switch 'github-bot/gh-2020'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2020'
git switch 'main'
git merge --squash 'github-bot/gh-2020'
git switch 'main'
git merge --ff-only 'github-bot/gh-2020'
git switch 'main'
git merge 'github-bot/gh-2020'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.