You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
vulkan_replay: continue prepare() after KHR TLAS ARRAY_OF_POINTERS build - #8267
Inside prepare()'s command loop in runtime/src/vulkan_replay.h (line 3047), the KHR TLAS ARRAY_OF_POINTERS branch returned the result of vk.prepare_khr_instances(*build, p.khr_instances) unconditionally:
if (build->is_tlas && build->instance_pointers && build->instance_count) {
if (!vk.prepare_khr_instances || !vk.host_at || !vk.buffer_at) return ReplayResult::unsupported;
return vk.prepare_khr_instances(*build, p.khr_instances);
}
When prepare_khr_instances succeeded (ReplayResult::success), prepare() exited the loop immediately:
No command after the TLAS build was prepared (Prepared entries kept VK_NULL_HANDLE handles, wrote_readback / readback_src_stages missed trailing readback copies, and emit() ran against unprepared commands).
Trailing invalid/unresolved commands were never rejected.
Post-loop query checks and planning (plan_statistics_segments / plan_occlusion_segments) were skipped.
Fix
Check prepare_khr_instances and return early only when r != ReplayResult::success, matching every other helper in prepare().
Add a portable CPU regression test runtime/test/replay_khr_tlas_tail_test.cpp (registered as replay_khr_tlas_tail in runtime/CMakeLists.txt) covering:
Trailing CopyBuffer (into a host_readable buffer) and Dispatch after a KHR ARRAY_OF_POINTERS TLAS build (both prepare() state and emit() calls).
Two consecutive KHR ARRAY_OF_POINTERS TLAS builds.
Rejection of an unresolved command after the TLAS build.
Post-loop overlapping occlusion query planning (plan_occlusion_segments) around the TLAS build.
Preserved error propagation when prepare_khr_instances fails.
The reason will be displayed to describe this comment to others. Learn more.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Built cleanly with MSVC (0 new warnings) across replay_khr_tlas_tail_test, vk_command_replay_test, and d3d12_dxr_validation_test.
Audited runtime/src/vulkan_replay.h:3032-3085: the early unconditional return vk.prepare_khr_instances(...) at line 3047 was the only stray success return inside prepare()'s command loop; replacing it with an error-only return cleanly restores preparation of trailing commands and post-loop query planning while preserving error propagation.
The fix is right: before it, a successful prepare_khr_instances returned from prepare() in the middle of the command loop, so everything after the first ARRAY_OF_POINTERS TLAS build (copies, readbacks, dispatches, a second TLAS build, the query planning after the loop) was never prepared. Errors still propagate. No issues found.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claimed in #8047 (#8047 (comment)). Depends on: none. Regression introduced in cc4b374 (#4060).
Problem
Inside
prepare()'s command loop inruntime/src/vulkan_replay.h(line 3047), the KHR TLASARRAY_OF_POINTERSbranch returned the result ofvk.prepare_khr_instances(*build, p.khr_instances)unconditionally:When
prepare_khr_instancessucceeded (ReplayResult::success),prepare()exited the loop immediately:Preparedentries keptVK_NULL_HANDLEhandles,wrote_readback/readback_src_stagesmissed trailing readback copies, andemit()ran against unprepared commands).plan_statistics_segments/plan_occlusion_segments) were skipped.Fix
prepare_khr_instancesand return early only whenr != ReplayResult::success, matching every other helper inprepare().runtime/test/replay_khr_tlas_tail_test.cpp(registered asreplay_khr_tlas_tailinruntime/CMakeLists.txt) covering:CopyBuffer(into ahost_readablebuffer) andDispatchafter a KHRARRAY_OF_POINTERSTLAS build (bothprepare()state andemit()calls).ARRAY_OF_POINTERSTLAS builds.plan_occlusion_segments) around the TLAS build.prepare_khr_instancesfails.Tested
replay_khr_tlas_tail_testfailed 10/10 assertions on unpatchedmain(dde82f27e).replay_khr_tlas_tail_test: PASS (replay KHR TLAS ARRAY_OF_POINTERS tail preparation OK).LEONIDA_VK_VALIDATION=1 ctest --test-dir runtime/build/linux --output-on-failure: 63 passed, 1 skipped (shader_library_corpus, no game files), 1 pre-existing failure (vk_queue, 10 sync-validation hazards in backlog test;vk_queuepasses 1/1 withoutLEONIDA_VK_VALIDATION=1).python3 -I scripts/check_no_game_data.py runtime/src/vulkan_replay.h runtime/CMakeLists.txt runtime/test/replay_khr_tlas_tail_test.cpp: PASS.Synthetic tests only, no game files. AI-assisted.