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

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2267
Author: @Tyrannys
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: rt-title-texture-show-after-upload


📝 Commits (1)

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

📊 Changes

3 files changed (+100 additions, -2 deletions)

View changed files

📝 runtime/CMakeLists.txt (+4 -0)
📝 runtime/shims/d3d12_vulkan_device.cpp (+26 -1)
📝 runtime/test/d3d12_existing_heap_test.cpp (+70 -1)

📄 Description

Claimed in the coordination issue as: RT-TITLE-TEXTURE-SHOW-AFTER-UPLOAD (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7185889059)

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


🔄 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/2267 **Author:** [@Tyrannys](https://github.com/Tyrannys) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `rt-title-texture-show-after-upload` --- ### 📝 Commits (1) - [`7fa9385`](https://github.com/ubiquitarianism/leonida/commit/7fa9385621a9fbd6f6ed0af14ca9e60b6ec947fc) d3d12: show a staged slot-70 texture only after its first upload (RT-TITLE-TEXTURE-SHOW-AFTER-UPLOAD) ### 📊 Changes **3 files changed** (+100 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `runtime/CMakeLists.txt` (+4 -0) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+26 -1) 📝 `runtime/test/d3d12_existing_heap_test.cpp` (+70 -1) </details> ### 📄 Description Claimed in the coordination issue as: `RT-TITLE-TEXTURE-SHOW-AFTER-UPLOAD` (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7185889059) ### 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) --- <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#2271
No description provided.