Skip to content

vulkan_replay: a KHR TLAS build of instance pointers no longer ends prepare() (RT-REPLAY-KHR-TLAS-POINTERS-RETURN) - #2526

Closed
Tyrannys wants to merge 1 commit into
ProjectLeonida:mainfrom
Tyrannys:rt-replay-khr-tlas-pointers-return
Closed

Tyrannys wants to merge 1 commit into
ProjectLeonida:mainfrom
Tyrannys:rt-replay-khr-tlas-pointers-return

Conversation

@Tyrannys

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: RT-REPLAY-KHR-TLAS-POINTERS-RETURN (#1608 (comment))

What and why

Item 1 of @kevincommits' finding in #1608 (#1608 (comment)). Thanks for the repro.

In prepare() (runtime/src/vulkan_replay.h), a KHR TLAS build with instance_pointers (D3D12_ELEMENTS_LAYOUT_ARRAY_OF_POINTERS) and instances did return vk.prepare_khr_instances(*build, p.khr_instances);. On success that left the command loop at the build:

  • every later command of the list stayed default-initialized: a dispatch had no pipeline (dropped at emit), a draw had no prepared draw, a later build had no structure;
  • the end-of-list query checks and the statistics and occlusion segment plans did not run.

The XDXR path a few lines above returns only a failure. The KHR path now does the same, with a comment.

Overlap: none found among open PRs touching vulkan_replay.h (#2486 changes KHR BLAS geometry and prebuild sizes, not this branch). Items 2 and 3 of the same finding come as separate PRs (#2523 is item 3).

Tested

Windows 11, MSVC (VS 18), RelWithDebInfo, on main 431ceba. CPU only.

  • New replay_khr_tlas_pointers_test (fake structures, buffers and pipeline):
    • kevincommits' repro: the TLAS build, then a dispatch and a BLAS build. prepare() succeeds, the instances are staged once (khr_instances set), the dispatch has its pipeline and the BLAS build its structure;
    • a staging that fails still fails the list with its own result.
  • With main's vulkan_replay.h, the two "later command" checks fail; all pass with the change.
  • ctest -R "^(replay_khr_tlas_pointers|replay_khr_as_copy_postbuild)$": 2/2 pass.
  • scripts/check_no_game_data.py: clean.

Not tested: a real KHR TLAS build on a GPU, and a game boot.

GPUs tested: profile M: NVIDIA GeForce RTX 4070 SUPER, 12 GB, desktop, driver 621.01, Windows 11 (CPU tests only)

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

…repare()

From kevincommits' finding (item 1) in ProjectLeonida#1608.

For a KHR TLAS build with D3D12_ELEMENTS_LAYOUT_ARRAY_OF_POINTERS, prepare()
returned prepare_khr_instances' result directly. On success it left the
command loop at that build: every later command of the list stayed
default-initialized (a dispatch with no pipeline, a draw with no prepared
draw), and the end-of-list query checks and the statistics and occlusion
segment plans did not run. Only a failure returns there now, as on the
XDXR path a few lines above.

New CPU test replay_khr_tlas_pointers: the TLAS build followed by a dispatch
and a BLAS build; both later commands are prepared (2 checks fail on main),
and a failed staging still fails the list with its own result.

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

Copy link
Copy Markdown
Contributor

Reviewed at head 2e3464a51 on Windows 11 (MSVC 2022 19.44).

Verification

  • Built replay_khr_tlas_pointers_test and gta6rt.
  • replay_khr_tlas_pointers_test: ok.

Notes

  • Removing the premature return after KHR TLAS instance-pointer staging (vulkan_replay.h:4192-4204) lets prepare() continue through subsequent commands and end-of-list validation, while staging failure still propagates its exact ReplayResult.
  • Emission binds the staged pointer array with arrayOfPointers (vulkan_replay.h:5445-5453), and vulkan_backend.h properly recycles abandoned stages on error and submitted stages after retirement (3217-3225, 4294-4303). The test verifies both the later dispatch/BLAS handle and the staging failure path.

Approve.

AI-assisted review + local MSVC verification.

@zmasi

zmasi commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

#2526 | head 2e3464a (merged cleanly with main 09c1539) | ctest --test-dir runtime/build -C RelWithDebInfo -R "^(replay_khr_tlas_pointers|replay_khr_as_copy_postbuild|xbox_bvh_builder)$" --output-on-failure (LEONIDA_VK_VALIDATION=1) | red on main: replay_khr_tlas_pointers_test fails (2 failure(s): prepare() returned immediately after prepare_khr_instances(), leaving the subsequent dispatch's pipeline null and subsequent BLAS build's accel_dst unprepared) | green on PR+main: 3/3 CTests pass (replay_khr_tlas_pointers in 0.07s, replay_khr_as_copy_postbuild in 0.06s, and xbox_bvh_builder 26/26 checks on RTX 3090 in 1.80s with LEONIDA_VK_VALIDATION=1 and 0 Khronos validation errors); check_no_game_data.py 0 violations | Windows 11, RTX 3090 (610.88), Vulkan SDK 1.4.363.1 | AI-assisted: yes

@DadaCap

DadaCap commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

Thanks for this! Closing it as a duplicate of #599 after a maintainer check that compared the two diffs commit by commit, not just the titles.

This is the same one-line fix in vulkan_replay.h prepare() as #599, which is older. We tested #599 locally (its test fails on main and passes with it) and are keeping it; it still needs a rebase on main. If #599 can't land, this one can be reopened as the fallback.

If you think something here is not covered by #599, say so and we'll reopen it.

AI-assisted (Claude Code), posted for DadaCap (maintainer).

@DadaCap DadaCap closed this Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants