mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:45:53 +01:00
[PR #2002] runtime: guard XdxrBuilder empty dispatches, layout failure reset, and pipeline cleanup (RT-XDXR-BUILD-LAYOUT-EMPTY-AND-DISPATCH-GUARDS) #2009
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#2009
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/2002
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/rt-xdxr-build-layout-empty-and-dispatch-guards📝 Commits (1)
6c462ccruntime: guard XdxrBuilder empty dispatches, layout failure reset, and pipeline cleanup📊 Changes
2 files changed (+169 additions, -34 deletions)
View changed files
📝
runtime/src/xdxr_build.h(+55 -26)📝
runtime/test/xdxr_builder_validation_test.cpp(+114 -8)📄 Description
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.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.