d3d12: show a staged slot-70 texture only after its first upload (RT-TITLE-TEXTURE-SHOW-AFTER-UPLOAD) #2267

Open
github-bot wants to merge 1 commit from github-bot/gh-2267 into main AGit
Owner

@⁠Tyrannys on GitHub · 2026-11-26 11:50 UTC · original
Tyrannys:rt-title-texture-show-after-upload → main · +100 −2 · 3 files · 1 commits · open

Claimed in the coordination issue as: RT-TITLE-TEXTURE-SHOW-AFTER-UPLOAD (#1608)

What and why

A slot-70 texture the layer makes itself (make_title_texture, TitleImageOrigin::streamed) and fills through the staged upload (TitleImageUpload, no host image copy for it) had its T#s bound in the bindless set from its first view on (register_bound_texture at creation, tracker layout UNDEFINED). Its first upload runs later:

  • always with LEONIDA_TITLE_FILL_ASYNC=1: the view queues the fill for the worker and writes the descriptor at once;
  • in the default inline mode whenever the first fill is skipped (pages not readable at that moment, a guarded copy that fails, write_staged_title_image timing out on pending present work).

In that window a shader sampling the T# reads an image that was never written and is still UNDEFINED, and a draw on another queue can run while the upload's UNDEFINED -> TRANSFER_DST barrier rewrites it (TitleImageUpload::submit makes only later submissions on other queues wait for it). Reading an uninitialised image with compression metadata is the kind of thing that can fault on some GPUs.

Fix: such a texture keeps its T#s pending (pending_image_keys; they read the fallback at index 0, as a pending_stream texture's already do) until publish_streamed_texture, which fill_title_texture and the fill worker's fill_unlocked call right after the first upload has been submitted. The upload already orders every later submission behind it (image barrier on its own queue, timeline-semaphore wait on the others), so any draw that can see the image sees it uploaded. Memory is still bound at creation; only the descriptor waits. No CPU or device waits are added. LEONIDA_TITLE_SHOW_AFTER_UPLOAD=0 restores the old behaviour for A/B runs.

Not changed: placed (slot-133) staged images and host-copy images (those are zero-filled in GENERAL at creation).

Idea from codec-d/cool_fox docs/findings.md ("a slot showed it before its upload had run", VICTORY_SHOW_AFTER), idea only, no code taken.

Overlap note: #2240 (RT-TITLE-TEXTURE-MAP-GEN) also touches the TitleTexture path (title_texture_readable) and adds a case to d3d12_existing_heap_test.cpp. The logic does not overlap (this PR changes Resource::create_texture and the fill worker); the test file may need a trivial merge in main().

Tested

  • New d3d12_title_show_after_upload (d3d12_existing_heap_test --title-show-after-upload): on a device without host image copies, with LEONIDA_TITLE_FILL_ASYNC=1 and a new test knob LEONIDA_TITLE_FILL_DELAY_MS=500 (slow fill worker), writes a slot-70 view of readable synthetic pages and checks the T# has no bindless entry before the upload and has one after it. Passes with the fix; fails with LEONIDA_TITLE_SHOW_AFTER_UPLOAD=0 (the old behaviour: "the T# names the image before its upload"). Also passes with LEONIDA_VK_VALIDATION=1 (no validation errors; the Khronos layer reports objects still alive at vkDestroyDevice in this mode, with or without the fix, because the retired test texture is released by the 3 s retirement sweep, after the test ends).
    Synchronization validation cannot see a bindless read of an UNDEFINED image, so the test checks the ordering through the bindless table instead.
  • d3d12_existing_heap, d3d12_existing_heap_no_write_watch, d3d12_existing_heap_write_watch, d3d12_host_prefix, d3d12_mapped_plane_async: pass.
  • Full runtime suite: ctest -j 4 while a boot ran on the same GPU: 472 of 478 passed. 4 of the 6 failures were timeouts/flakes under that load and pass when rerun alone (xs_proxy_mock, d3d12_queue_wait_timeout, d3d12_queue_list_type, d3d12_sparse_queue_family_contract). xbox_present (present VkResult -11) and d3d12_set_descriptor_heaps (line 353, recorded_commands) fail the same way with upstream/main's d3d12_vulkan_device.cpp built in the same tree, so they are not from this change.
  • No game data; synthetic pages only.

GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 621.01, Windows 11

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

**@⁠Tyrannys** on GitHub · 2026-11-26 11:50 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2267) `Tyrannys:rt-title-texture-show-after-upload` → `main` · +100 −2 · 3 files · 1 commits · open Claimed in the coordination issue as: `RT-TITLE-TEXTURE-SHOW-AFTER-UPLOAD` (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) ### What and why A slot-70 texture the layer makes itself (`make_title_texture`, `TitleImageOrigin::streamed`) and fills through the staged upload (`TitleImageUpload`, no host image copy for it) had its T#s bound in the bindless set from its first view on (`register_bound_texture` at creation, tracker layout `UNDEFINED`). Its first upload runs later: - always with `LEONIDA_TITLE_FILL_ASYNC=1`: the view queues the fill for the worker and writes the descriptor at once; - in the default inline mode whenever the first fill is skipped (pages not readable at that moment, a guarded copy that fails, `write_staged_title_image` timing out on pending present work). In that window a shader sampling the T# reads an image that was never written and is still `UNDEFINED`, and a draw on another queue can run while the upload's `UNDEFINED -> TRANSFER_DST` barrier rewrites it (`TitleImageUpload::submit` makes only *later* submissions on other queues wait for it). Reading an uninitialised image with compression metadata is the kind of thing that can fault on some GPUs. Fix: such a texture keeps its T#s pending (`pending_image_keys`; they read the fallback at index 0, as a `pending_stream` texture's already do) until `publish_streamed_texture`, which `fill_title_texture` and the fill worker's `fill_unlocked` call right after the first upload has been submitted. The upload already orders every later submission behind it (image barrier on its own queue, timeline-semaphore wait on the others), so any draw that can see the image sees it uploaded. Memory is still bound at creation; only the descriptor waits. No CPU or device waits are added. `LEONIDA_TITLE_SHOW_AFTER_UPLOAD=0` restores the old behaviour for A/B runs. Not changed: placed (slot-133) staged images and host-copy images (those are zero-filled in `GENERAL` at creation). Idea from codec-d/cool_fox `docs/findings.md` ("a slot showed it before its upload had run", `VICTORY_SHOW_AFTER`), idea only, no code taken. Overlap note: #2240 (RT-TITLE-TEXTURE-MAP-GEN) also touches the TitleTexture path (`title_texture_readable`) and adds a case to `d3d12_existing_heap_test.cpp`. The logic does not overlap (this PR changes `Resource::create_texture` and the fill worker); the test file may need a trivial merge in `main()`. ### Tested - New `d3d12_title_show_after_upload` (`d3d12_existing_heap_test --title-show-after-upload`): on a device without host image copies, with `LEONIDA_TITLE_FILL_ASYNC=1` and a new test knob `LEONIDA_TITLE_FILL_DELAY_MS=500` (slow fill worker), writes a slot-70 view of readable synthetic pages and checks the T# has no bindless entry before the upload and has one after it. Passes with the fix; **fails** with `LEONIDA_TITLE_SHOW_AFTER_UPLOAD=0` (the old behaviour: "the T# names the image before its upload"). Also passes with `LEONIDA_VK_VALIDATION=1` (no validation errors; the Khronos layer reports objects still alive at `vkDestroyDevice` in this mode, with or without the fix, because the retired test texture is released by the 3 s retirement sweep, after the test ends). Synchronization validation cannot see a bindless read of an `UNDEFINED` image, so the test checks the ordering through the bindless table instead. - `d3d12_existing_heap`, `d3d12_existing_heap_no_write_watch`, `d3d12_existing_heap_write_watch`, `d3d12_host_prefix`, `d3d12_mapped_plane_async`: pass. - Full runtime suite: `ctest -j 4` while a boot ran on the same GPU: 472 of 478 passed. 4 of the 6 failures were timeouts/flakes under that load and pass when rerun alone (`xs_proxy_mock`, `d3d12_queue_wait_timeout`, `d3d12_queue_list_type`, `d3d12_sparse_queue_family_contract`). `xbox_present` (present VkResult -11) and `d3d12_set_descriptor_heaps` (line 353, `recorded_commands`) fail the same way with `upstream/main`'s `d3d12_vulkan_device.cpp` built in the same tree, so they are not from this change. - No game data; synthetic pages only. GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 621.01, Windows 11 AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A slot-70 texture the layer makes itself (TitleImageOrigin::streamed) and fills
through the staged upload had its T#s bound in the bindless set from its first
view on. A draw before the first fill (always with LEONIDA_TITLE_FILL_ASYNC=1,
and whenever an inline fill is skipped) sampled an image never written and still
in UNDEFINED layout, and a draw on another queue could overlap the upload's
UNDEFINED -> TRANSFER_DST transition of it.

Such a texture now keeps its T#s pending (they read the fallback at index 0)
until publish_streamed_texture, which runs after the first upload has been
submitted. TitleImageUpload::submit already orders every later submission
behind that upload (an image barrier on its queue, a timeline wait on the
others), so a draw that can see the image sees it uploaded. Memory is still
bound at creation; only the descriptor waits. LEONIDA_TITLE_SHOW_AFTER_UPLOAD=0
restores the old behaviour.

Idea from codec-d/cool_fox docs/findings.md (VICTORY_SHOW_AFTER); idea only,
no code taken.

Test: d3d12_title_show_after_upload (LEONIDA_TITLE_FILL_ASYNC=1 with a new
LEONIDA_TITLE_FILL_DELAY_MS slow fill worker) checks the T# has no bindless
entry before the upload and has one after it. It fails with
LEONIDA_TITLE_SHOW_AFTER_UPLOAD=0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:53:06 +00:00
This pull request has changes conflicting with the target branch.
  • runtime/test/d3d12_existing_heap_test.cpp
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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