Skip to content

d3d12_title_va_test: a BLAS build in title memory no resource covers (RT-BVH-BUILD-TITLE-VA) - #1816

Open
Snooozs wants to merge 3 commits into
ProjectLeonida:mainfrom
Snooozs:bvh-build-title-va-test
Open

Snooozs wants to merge 3 commits into
ProjectLeonida:mainfrom
Snooozs:bvh-build-title-va-test

Conversation

@Snooozs

@Snooozs Snooozs commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Item: RT-BVH-BUILD-TITLE-VA (#1608). Test only.

I claimed this item to translate the addresses of acceleration-structure builds. #1723 merged that fix first, and it covers more (the BLAS addresses in TLAS instances, copies sized by the build), so my version is dropped. What is left is one case its tests don't have.

d3d12_xdxr_rt_test builds into slot-133 buffers. The new check_bvh_build in d3d12_title_va_test builds a BLAS with the vertices, indices, destination and scratch all in the title's own memory and no resource over any of it, so every address goes through a title window. The test shader reads the header back at the destination and it must have the triangles' bounds. Before anything is submitted, the test checks that every address got a GPU copy, so a missing translation fails without losing the device.

The check is skipped with LEONIDA_GEOMETRY_MB > 0 (d3d12_geometry_views), like the geometry-only checks next to it are skipped without it.

Tested on RTX 5060 Ti, driver 621.01, Windows 10 22H2, main 0d80bc5df:

  • d3d12_title_va and d3d12_title_va_shadow pass, bounds -5 0 1 to 4 8 9. d3d12_com, d3d12_xdxr_rt, xbox_bvh_builder, d3d12_rebound_* and d3d12_api_descriptor_copy* pass.
  • Negative control: with LEONIDA_RT_AS=off the builds are dropped, and the test fails at the address check, before the submission.
  • d3d12_geometry_views fails on this machine, at !root_blob.empty() in main, before any check runs (the Windows 10 host serializer returned no blob for the heap-directly-indexed root signature). This change does not touch that code. I did not run it on main without the change.
  • Not run in the game.

Noticed while placing the check: a stream pool's two alias ranges stay in the table after the pool's memory is freed (remove_title_memory and dropping the pair do not remove them). When the test allocated its block at those addresses, two parts of it shared one copy and the build read zeros. That is why the check runs before check_stream_pool. Whether the retail title ever reuses a pool's addresses I have not checked.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

d3d12_xdxr_rt_test builds into slot-133 buffers. Nothing built with every
address (vertices, indices, destination, scratch) in the title's own
memory with no resource over it, which is reached through title windows.
The header read back at the destination must have the triangles' bounds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@potatoe0100

Copy link
Copy Markdown
Contributor

Tested on Windows 11 (26300), NVIDIA GeForce RTX 4060, driver 621.14, VS 2022 RelWithDebInfo + Ninja, merged onto main 384abe5: d3d12_title_va and d3d12_title_va_shadow pass with the same bounds (-5 0 1 to 4 8 9), and d3d12_geometry_views, d3d12_xdxr_rt, xbox_bvh_builder*, xdxr_build* and vk_xdxr_postbuild_readback pass too. So d3d12_geometry_views passes on Windows 11 here, and the !root_blob.empty() failure you saw looks specific to the Windows 10 serializer. Negative control repeated: with LEONIDA_RT_AS=off, d3d12_title_va fails. Test-only change, and it reads fine to me.

AI-assisted (Claude).

@PierreEbele

Copy link
Copy Markdown
Contributor

Reviewed cf8490c: coverage-only addition. I only read the code for the new check (it needs Windows + MSVC + GPU, so it was not executed): the dispatch mirrors check_title_memory's proven root-view pattern, and the asserted box at destination bytes 16-39 matches MODE_HEADER in runtime/src/xdxr_build.comp, with expected bounds {-5,0,1}/{4,8,9} correct for the six vertices. What did run (Linux): check_no_game_data.py on the file -> clean; the portable title_va_alias test builds and passes on the PR tree; Linux-built sources are unchanged from main. A GPU run of the d3d12_title_va / d3d12_title_va_shadow ctest entries remains the one open check. Nits: the check never bumps the checks counter its siblings do, and the file header could note that LEONIDA_RT_AS=khr/off in a user environment would fail this check. No finding. AI-assisted review.

Recommendation: Merge

@Snooozs

Snooozs commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @potatoe0100 and @PierreEbele.

  • Merged current main (be2f402) into the branch; it was on 0d80bc5, which may be why the linux-gpu-tools and macos jobs of the last run failed (cs_imgatomic_ext there). This change adds a Windows test and can't reach those jobs.
  • The two nits are in: the check counts itself (checks), and the comment on it names LEONIDA_RT_AS=khr and off as what fails it.
  • The open check, the GPU run: RTX 5060 Ti, NVIDIA 621.01, Windows 10 19045, MSVC, on the merged branch: d3d12_title_va, d3d12_title_va_shadow and d3d12_title_window_cap pass. Negative control again: with LEONIDA_RT_AS=off d3d12_title_va_test stops at the address check before the submission.

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

Snooozs added a commit to Snooozs/leonida that referenced this pull request Nov 25, 2026
…fail it

Review notes by PierreEbele on ProjectLeonida#1816.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fail it

Review notes by PierreEbele on ProjectLeonida#1816.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Snooozs

Snooozs commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

The red CI jobs here are failures that main has now too, each with an open fix:

Nothing in this PR touches those files. AI-assisted (Claude Code).

@BadgersMC

Copy link
Copy Markdown
Contributor

Independent native Windows GPU check of 97070ee127 merged locally onto upstream fbf100b1b1 (#2350). The merge was clean and the staged diff touched only runtime/test/d3d12_title_va_test.cpp.

  • d3d12_title_va, d3d12_title_va_shadow, and d3d12_title_window_cap all passed. The two BVH readbacks each returned the expected bounds, (-5, 0, 1) to (4, 8, 9).
  • Negative control: LEONIDA_RT_AS=off failed at aliases.shader_va(va + at) != va + at before submitting the BVH command list. This confirms the fixture detects the missing address translation.

RTX 3060 Ti 8 GiB, NVIDIA 610.88, Windows 11 build 26100, MSVC 19.44 RelWithDebInfo. Synthetic inputs only. AI-assisted testing.

@Snooozs
Snooozs force-pushed the bvh-build-title-va-test branch from 97070ee to 1eea816 Compare November 27, 2026 15:34
@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 27, 2026
@MoonEyes

Copy link
Copy Markdown
Collaborator

Hi @Snooozs, thanks for this pull request. It currently conflicts with main (conflicting file(s): runtime/test/d3d12_title_va_test.cpp), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

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

@enlight3d

Copy link
Copy Markdown
Contributor

Run of this pull request on a second machine (head only: this branch does not merge cleanly into current main).

Heads: PR head 1eea816 (3 commits, includes a merge of an older main; merge-base with current main be2f402), current main 8fb9748.
Merge into main: conflict in runtime/test/d3d12_title_va_test.cpp. I therefore built and tested the PR head itself (detached), not a merge.

Commands (RelWithDebInfo, Ninja, -DLEONIDA_REQUIRE_VULKAN=ON):

git checkout --detach pr-1816
cmake --build runtime/build --target d3d12_title_va_test d3d12_com_test d3d12_xdxr_rt_test xbox_bvh_builder_test gta6rt -j 8
ctest -R "^(d3d12_title_va|d3d12_title_va_shadow|d3d12_geometry_views|d3d12_api_descriptor_copy|d3d12_api_descriptor_copy_off|d3d12_rebound_tables|d3d12_rebound_tables_off|d3d12_rebound_second_device|d3d12_com|d3d12_xdxr_rt|xbox_bvh_builder)$" --output-on-failure -j1

Green: 11/11 pass, all on the RTX 3090. The new check runs in d3d12_title_va (verbose output: "acceleration-structure build in title memory: bounds -5 0 1 to 4 8 9", same as the PR's). d3d12_geometry_views also passes here (it failed on the author's Windows 10 machine).

Red: none to give. This pull request only adds a test (no non-test change to revert), and its fix is already in main through #1723, so there is no failing state of the code to show. Negative control (the one the PR describes): with LEONIDA_RT_AS=off, d3d12_title_va fails at d3d12_title_va_test.cpp:892 (aliases.shader_va(va + at) != va + at, the address check before any submission), as the PR says.

Link: gta6rt.exe of the PR head vs gta6rt.exe of main 8fb9748 (dumpbin /imports, DLL!symbol, sorted): the only import present in the head and not in main is api-ms-win-crt-stdio-l1-1-0.dll!__stdio_common_vswscanf. It comes from the older base (main has since changed an swscanf call), not from this change, which touches only a test. No other new imports.

Machine: RTX 3090 24 GB, NVIDIA 621.40, Windows 11 Pro 10.0.26300, MSVC 19.44, Vulkan SDK 1.4.363.1.

The branch conflicts with current main in the test file above; could you merge main into it? Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants