runtime: guard XdxrBuilder empty dispatches, layout failure reset, and pipeline cleanup (RT-XDXR-BUILD-LAYOUT-EMPTY-AND-DISPATCH-GUARDS) #2002
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2002"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-25T17:55:32Z.
Claim:
RT-XDXR-BUILD-LAYOUT-EMPTY-AND-DISPATCH-GUARDS(claim comment#7170142282on #1608).Problem
In
runtime/src/xdxr_build.h:XdxrLayout::compute()populatedtlas,box16,node_size,elements,element_size, andnodesbefore checking the 32-bit offset / 29-bit unit limit and returningfalse, leaving a failed layout partially initialized.tiles()andkept_tiles():(sort_size + radix_tile - 1) / radix_tileand(inner() + radix_tile - 1) / radix_tilewrapuint32_tnearUINT32_MAX(returning0instead of2^24).finish()unconditionally dispatchedmode_mortonwithcount = l.sort_size, emittingvkCmdDispatch(cb, 0, 1, 1)and a compute-to-computevkCmdPipelineBarrierwheneversort_size == 0.64 * tilesround-trip:finish()multiplied tile group counts by 64 (64 * l.tiles(),64 * l.kept_tiles()) beforedispatch()divided back by 64, which can overflowuint32_tfor large tile counts.VkCommandBufferand partialmake_pipeline()cleanup:record_blas/record_tlas/record_copy/record_postbuilddid not guard!cb, andmake_pipeline()leftlayout_alive onvkCreateShaderModuleorvkCreateComputePipelinesfailure until~XdxrBuilder().Fix
*this = XdxrLayout{};before returningfalseon overflow inXdxrLayout::compute().tiles()andkept_tiles()overflow-free (n ? 1u + (n - 1u) / radix_tile : 0u).dispatch_groups()(skippinggroups == 0), guard!threadsindispatch(), skipmode_mortonwhenl.sort_size == 0, and dispatch exact tile/workgroup counts directly infinish().!cbinrecord_blas,record_tlas,record_copy, andrecord_postbuild.VkPipelineLayout/VkPipelinehandles inmake_pipeline(), destroyinglayoutimmediately on shader-module or pipeline failure so a failedXdxrBuilderkeepslayout_andpipeline_null.runtime/test/xdxr_builder_validation_test.cpp(0CMakeLists.txtedits) to cover all 5 fixes.Verification
runtime/test/xdxr_builder_validation_test.cppcleanly under:clang++ -std=c++20 -O1 -g -fsanitize=address,undefined -Wall -Wextra -Werror -Wno-missing-field-initializersclang++ -std=c++20 -O1 -g -fsanitize=thread -Wall -Wextra -Werror -Wno-missing-field-initializersclang++ -std=c++20 -O2 -Wall -Wextra -Werror -Wno-missing-field-initializerspython3 -I scripts/check_no_game_data.py runtime/src/xdxr_build.h runtime/test/xdxr_builder_validation_test.cppandpython3 -I tests/test_text_write_line_endings.py: all passed.Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T17:55:45Z.
Review: COMMENTED
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.
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T13:12:13Z.
#2002 | head
6c462cc77a(merged cleanly with maind48a957bb9) |ctest --test-dir runtime/build -C RelWithDebInfo -R "xdxr" --output-on-failure(LEONIDA_VK_VALIDATION=1) | red on main:xdxr_builder_validationfails atline 194: g_rec.binds == 1 && g_rec.dispatches == 3 && g_rec.zero_dispatches == 0 && g_rec.barriers == 2(rc=8) | green on PR+main: 8/8xdxrCTests pass (xdxr_builder_validation,xdxr_build_output,xdxr_descs,xdxr_build+xdxr_build_check0 ray mismatches across 30 BLAS/TLAS cases,d3d12_xdxr_rt+d3d12_xdxr_rt_check0 ray mismatches, andvk_xdxr_postbuild_readback) on RTX 3090 with0Khronos validation errors;check_no_game_data.py0violations | Windows 11, MSVC 19.44, RTX 3090, Vulkan SDK 1.4.363.1 | AI-assisted: yesImported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T17:55:03Z.
Red/green: On main xdxr_builder_validation fails at line 194 (an empty dispatch is not skipped, zero_dispatches != 0), and with the PR ctest -R "^xdxr_builder_validation$" passes.
Independent tester (OreoFR, RTX 4070, Windows 11): PR head merged with the other PRs of its batch on main
c1ecf04ed, full ctest run (485 tests, tests that launch the game excluded): no new failure compared with main.Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T21:57:48Z.
Verified by OreoFR
c1ecf04ed+ PR head6c462cc77; green run in a merge package of 16 PRs, no new ctest failure vs mainctest -R ^xdxr_builder_validation$AI-assisted (Claude Code, Claude Opus 5.5).