Repository navigation
Conversation
…TITLE-TEXTURE-SHOW-AFTER-UPLOAD) 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 <noreply@anthropic.com>
…ow-after-upload # Conflicts: # runtime/test/d3d12_existing_heap_test.cpp
|
Full runtime suite after the main merge (9fa1a8e, RTX 4070 SUPER, profile M): 490 of 492 pass; the 2 failures ( |
lixonik
left a comment
There was a problem hiding this comment.
Reviewed and locally tested at 9fa1a8ee9 (merged cleanly onto main ec91d695c).
Verification
- Environment: Windows 11, MSVC 19.44, NVIDIA GeForce RTX 5070 (driver 610.88, Vulkan 1.4.341;
VK_LAYER_KHRONOS_validationnot installed locally). ctest:d3d12_title_show_after_upload,d3d12_existing_heap, andd3d12_mapped_plane_asyncall passed (3/3).scripts/check_no_game_data.pyandgit diff --check: clean.
Review notes
- The deferral hooks cleanly into the existing
pending_image_keys/publish_streamed_texture()flow: placing the check after themem-probeblock preserves diagnostics, changing the final return todeferred_stream_ && deferred_bytes_ ? S_OK : register_bound_texture()ensures already-backed streamed images still register inVulkanContextbeforeupload_staged_title(), bothfill_unlocked()andfill_title_texture()publish on the first successful fill (t.owned && !t.fills), and~Resource()cleans uppending_image_keysif retired early. - Left one non-blocking inline note about non-
staged_title_/ non-host_transfer_streamedimages that also start inVK_IMAGE_LAYOUT_UNDEFINED.
AI-assisted.
| const char* value = std::getenv("LEONIDA_TITLE_SHOW_AFTER_UPLOAD"); | ||
| return !value || std::strcmp(value, "0"); | ||
| }(); | ||
| if (show_after_upload && origin == TitleImageOrigin::streamed && staged_title_ && !deferred_stream_) { |
There was a problem hiding this comment.
Non-blocking edge case: a TitleImageOrigin::streamed texture can also start in VK_IMAGE_LAYOUT_UNDEFINED when both host_transfer_ and staged_title_ are false -- e.g., rgb96 formats, a color format on a host-image-copy-capable GPU that lacks VK_FORMAT_FEATURE_2_HOST_IMAGE_TRANSFER_BIT_EXT, LEONIDA_TITLE_IMAGE_STAGING=0, or a retry_host() fallback when host_image_copy is unavailable. Those images are filled via upload_title_subresource() in fill_title_texture() (which already calls publish_streamed_texture() when t.owned && !t.fills), so checking !host_transfer_ instead of staged_title_ would cover them too if desired.
Also, adding LEONIDA_TITLE_SHOW_AFTER_UPLOAD to the env-var table in runtime/README.md would keep the docs in sync.
There was a problem hiding this comment.
Thanks @lixonik, good find. Covered in e6fa554: the deferral now keys on !host_transfer_ instead of staged_title_. Those textures are filled through WriteToSubresource's staging copy, which is submitted and waited for, and fill_title_texture / the fill worker already call publish_streamed_texture() after the first fill, so they are shown once filled, like the staged ones. Host-transfer images start in GENERAL and are filled on the host, so they are still shown at once.
New test d3d12_title_show_after_upload_unstaged (LEONIDA_TITLE_IMAGE_STAGING=0 on a device without host image copy, so the texture is neither staged nor host-copied):
- with the old condition, the T# names the image before its fill (2/2 runs);
- with the change, it is hidden until the fill worker's upload, then shown (3/3 runs).
One case from the list can't reach this path: a 96-bit (R32G32B32_FLOAT) slot-70 view is a null view, because the XG model lacks the format, so no streamed texture is made for it.
LEONIDA_TITLE_SHOW_AFTER_UPLOAD is now in the README env table too. RTX 4070 SUPER, 621.01, Windows 11: 12/12 related tests pass (existing_heap|title_texture|placed|mapped_plane|show_after). AI-assisted (Claude Code).
… copy A slot-70 streamed texture that is neither staged nor host-transfer (a format without host-image transfer, LEONIDA_TITLE_IMAGE_STAGING=0 on a device without host copies, the retry_host fallback there) also starts UNDEFINED. It is filled through WriteToSubresource's waited staging copy, and fill_title_texture already publishes it after the first fill. The deferral now keys on !host_transfer_ instead of staged_title_, so these textures read the fallback until that fill too. Host-transfer images are made GENERAL and filled on the host, and are still shown at once. New test d3d12_title_show_after_upload_unstaged (LEONIDA_TITLE_IMAGE_STAGING=0, no host image copy): its T# named the image before the fill with the old condition (2/2 runs), and is hidden until the fill worker's upload with the new one (3/3). LEONIDA_TITLE_SHOW_AFTER_UPLOAD is now in the README's environment table. From lixonik's review of ProjectLeonida#2267. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lixonik
left a comment
There was a problem hiding this comment.
Re-reviewed e6fa5544f and tested on RTX 5070:
- Keying deferral on
!host_transfer_instead ofstaged_title_cleanly covers streamed slot-70 textures that startUNDEFINEDand fill throughWriteToSubresource's waited staging copy (formats without host-image transfer,LEONIDA_TITLE_IMAGE_STAGING=0, orretry_hostfallback), while host-transfer images remain shown immediately.LEONIDA_TITLE_SHOW_AFTER_UPLOADis also documented inruntime/README.md. - Tested on NVIDIA GeForce RTX 5070 (Windows 11, driver 610.88, Vulkan 1.4.341, MSVC 19.44;
VK_LAYER_KHRONOS_validationnot installed locally):d3d12_title_show_after_upload: passed (0.73 s).d3d12_title_show_after_upload_unstaged: passed (0.69 s).
Looks good to merge.
AI-assisted (Antigravity, Gemini).
|
#2267 | head e6fa554 (merged cleanly with main ba8b77b — no conflicts on current |
timbot103
left a comment
There was a problem hiding this comment.
Static audit of e6fa5544f against the patch base and the supplied main snapshot. No builds, tests, or GPU runs.
- [MAJOR]
runtime/shims/d3d12_vulkan_device.cpp:9293— The unstaged fallback still publishes early if the source pages are unreadable on the first view. With host image copy unavailable andLEONIDA_TITLE_IMAGE_STAGING=0, the default image deferral choosespending_stream. The branch at line 9190 only inserts a pending key for that origin when host transfer or dedicated title staging is available, and the new guard only coversstreamed. This leaves a bindless SRV for anUNDEFINEDimage while the fill is skipped. Please use the existingstreampredicate here and add a case that starts with uncommitted pages, commits them, and verifies that the original T# becomes visible after the fill. - [MINOR]
runtime/shims/d3d12_vulkan_device.cpp:16027—LEONIDA_TITLE_FILL_DELAY_MSis a runtime string literal with no tracked Markdown entry, sotests/test_docs_env_vars.pywill flag it in CI. Please document the default and test purpose inruntime/README.md. - [MINOR]
runtime/test/d3d12_existing_heap_test.cpp:1534— A device without bindless support reports a pass before either test checks visibility. Also, the staged case inherits the staging setting and can fall back to the waited copy path. Please report a CTest skip when prerequisites are missing and verify each mode exercised its intended upload path. - [MINOR]
runtime/test/d3d12_existing_heap_test.cpp:1567— The 500 ms delay lets the worker finish first if the test thread is delayed, so the early assertion can fail with correct publication. A test-controlled gate before upload would make both visibility assertions deterministic.
On the paths that enter deferral, failed fills leave the keys pending. The patch base publishes after the full upload succeeds, and the supplied main snapshot also gates partial-chain publication by the view's first mip. The descriptor lock protects key rebinding, and the staged uploader orders later submissions on the upload queue and on other queues. RTV, DSV, UAV, and resource-handle CopyDest operations use explicit resources. The new CTests are inside the Windows test block.
AI-assisted.
Claimed in the coordination issue as:
RT-TITLE-TEXTURE-SHOW-AFTER-UPLOAD(#1608 (comment))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_textureat creation, tracker layoutUNDEFINED). Its first upload runs later:LEONIDA_TITLE_FILL_ASYNC=1: the view queues the fill for the worker and writes the descriptor at once;write_staged_title_imagetiming 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'sUNDEFINED -> TRANSFER_DSTbarrier rewrites it (TitleImageUpload::submitmakes 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 apending_streamtexture's already do) untilpublish_streamed_texture, whichfill_title_textureand the fill worker'sfill_unlockedcall 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=0restores the old behaviour for A/B runs.Not changed: placed (slot-133) staged images and host-copy images (those are zero-filled in
GENERALat 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 tod3d12_existing_heap_test.cpp. The logic does not overlap (this PR changesResource::create_textureand the fill worker); the test file may need a trivial merge inmain().Tested
upstream/main2859d0c (with d3d12,xmem: sync TitleTexture readability against title_memory_map between passes (RT-TITLE-TEXTURE-MAP-GEN) #2240): the new test still passes with the fix and fails withLEONIDA_TITLE_SHOW_AFTER_UPLOAD=0(line 1564,!shown_early);title_memory_map,d3d12_existing_heap,d3d12_host_prefix,d3d12_mapped_plane_async,d3d12_existing_heap_no_write_watch,d3d12_existing_heap_write_watchpass. Full suite not rerun after the merge.d3d12_title_show_after_upload(d3d12_existing_heap_test --title-show-after-upload): on a device without host image copies, withLEONIDA_TITLE_FILL_ASYNC=1and a new test knobLEONIDA_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 withLEONIDA_TITLE_SHOW_AFTER_UPLOAD=0(the old behaviour: "the T# names the image before its upload"). Also passes withLEONIDA_VK_VALIDATION=1(no validation errors; the Khronos layer reports objects still alive atvkDestroyDevicein 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
UNDEFINEDimage, 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.ctest -j 4while 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) andd3d12_set_descriptor_heaps(line 353,recorded_commands) fail the same way withupstream/main'sd3d12_vulkan_device.cppbuilt in the same tree, so they are not from this change.Update after lixonik's review (e6fa554): the deferral also covers streamed textures that are neither staged nor host-transfer, which are filled through
WriteToSubresource's waited staging copy and also startUNDEFINED. New testd3d12_title_show_after_upload_unstaged(LEONIDA_TITLE_IMAGE_STAGING=0, no host image copy) fails with the old condition (2/2 runs) and passes with the change (3/3).LEONIDA_TITLE_SHOW_AFTER_UPLOADis now inruntime/README.md.GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 621.01, Windows 11 (profile M: RTX 4070 SUPER 12 GB desktop)
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code