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

Open
opened 2026-11-26 21:19:47 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2020
Author: @DadaCap
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: placed-defer-no-host-copy


📝 Commits (1)

  • e500e99 d3d12: CPU-fillable placed BC images share a zero image without host copies too

📊 Changes

3 files changed (+23 additions, -11 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+2 -1)
📝 runtime/shims/d3d12_vulkan_device.cpp (+17 -9)
📝 runtime/test/d3d12_existing_heap_test.cpp (+4 -1)

📄 Description

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


🔄 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/2020 **Author:** [@DadaCap](https://github.com/DadaCap) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `placed-defer-no-host-copy` --- ### 📝 Commits (1) - [`e500e99`](https://github.com/ubiquitarianism/leonida/commit/e500e994940dce9f2f9edb2ff2a29003bea162eb) d3d12: CPU-fillable placed BC images share a zero image without host copies too ### 📊 Changes **3 files changed** (+23 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+2 -1) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+17 -9) 📝 `runtime/test/d3d12_existing_heap_test.cpp` (+4 -1) </details> ### 📄 Description 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#2028
No description provided.