Repository navigation
d3d12, process: null barrier arrays, CopyTiles in a bundle, calibration wait, entry thread argument, getmainargs expand (RT-COM-NULL-BARRIERS-ENTRY) - #2522
Conversation
…on wait, entry thread and getmainargs expand From kevincommits' finding (item 4) in ProjectLeonida#1608. - d3d12_com.cpp: - ResourceBarrier: a count with no array fails the list (check(false)) instead of reading through null, as WriteBufferImmediate does. - Barrier: the same for a null group array, and for a group with barriers but no barrier array (the three array pointers are one union). - CopyTiles: a bundle is refused for reserved buffers too, not only for sparse images; no copy is allowed in a bundle. - submitted_calibration: vkGetQueryPoolResults asks VK_QUERY_RESULT_WAIT_BIT, so the read cannot answer VK_NOT_READY. - process.cpp: - run_entry passes the entry point itself to the game thread instead of a pointer to its own stack: another thread can end the run before the game thread first runs, and run_entry's frame is then gone. - __getmainargs/__wgetmainargs expand wildcards when `expand` is nonzero (mode 2, as _configure_*_argv does) and fail on a null argc or argv. Tests: d3d12_com_test (null arrays fail Close; counts of 0 and valid calls do not), d3d12_buffer_tiles_test (CopyTiles of a reserved buffer in a bundle fails Close), process_cmdline_test (expand 0 and 1, null argc/argv). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Reviewed at head Verification
Notes (non-blocking)
Approve. AI-assisted review + local MSVC/dual-GPU verification. |
|
#2522 | head d411fe9 (merged cleanly with main 09c1539) | |
lixonik
left a comment
There was a problem hiding this comment.
Reviewed the diff and tested merged onto main (493867366) with Ninja Release (MSVC) and LEONIDA_VK_VALIDATION=1.
The null barrier array guards, early CopyTiles bundle rejection, VK_QUERY_RESULT_WAIT_BIT on calibration readback, direct entry-point thread argument in run_entry (removing the stack-frame race), and __getmainargs/__wgetmainargs wildcard expansion + null checks are all clean and well-tested.
Tests run
ctest --output-on-failure -R "^(d3d12_com|d3d12_buffer_tiles|process_cmdline)$"(withLEONIDA_VK_VALIDATION=1): 3/3 passed (process_cmdline,d3d12_com0.28 s,d3d12_buffer_tiles1.53 s).
GPUs tested: NVIDIA GeForce RTX 5070 12 GB (Windows 11, driver 610.88, Vulkan 1.4.341, VK_LAYER_KHRONOS_validation 1.4.363).
AI-assisted (Antigravity, Gemini).
Claimed in the coordination issue as: RT-COM-NULL-BARRIERS-ENTRY (#1608 (comment))
What and why
Item 4 of @kevincommits' finding in #1608 (#1608 (comment)). Thanks for the line-by-line report.
runtime/shims/d3d12_com.cpp:ResourceBarrier:count > 0with a nullbarriersread through null. It now fails the list (check(false), soClosereturnsE_INVALIDARG), asWriteBufferImmediatealready does.Barrier: the same forgroups > 0with a nullgroup, and for a group withNumBarriers > 0and no barrier array. The three array pointers ofD3D12_BARRIER_GROUPare one union, so one check covers every type. A count of 0 still needs no array.CopyTiles: a bundle was refused only on the sparse-image path; a reserved buffer recorded a copy into the bundle. The check now comes first, as inCopyBufferRegionandCopyTextureRegion: no copy is allowed in a bundle.submitted_calibration:vkGetQueryPoolResultsnow passesVK_QUERY_RESULT_WAIT_BITwithVK_QUERY_RESULT_64_BIT, as labels: GPU timestamps wait for their query, others record none, store unlocked (RT-GPU-LABEL-COMPLETIONS) #2504 did for the GPU labels. The queue is waited idle before the read, so this is a guard againstVK_NOT_READYrather than a change measured here.runtime/shims/process.cpp:run_entry: the game thread got&call, a struct onrun_entry's stack. If another thread ended the run (end_run) before the game thread first ran,run_entryreturned and the game thread then read a dead frame. The entry point itself is now the thread's parameter; nothing ofrun_entry's frame is read.__getmainargs/__wgetmainargs:expand(the CRT's_dowildcard) was ignored. A nonzero value now expands wildcards (mode 2, as_configure_narrow_argv/_configure_wide_argvdo), and a nullargcorargvreturns -1 instead of being written through.Overlap: #841 and #2492 change other parts of
d3d12_com.cpp(bundleDispatchMesh,ExecuteIndirect), not these lines. #1564 changes the start and end ofrun_entry(exit-handler clearing and the cleanup lock), not the thread's argument; if one lands first the other may need a small rebase. #2405 and pepefroge's VULKAN-COPY-TILES-ALIGN claim touch the sparse and readback side of tile copies, not the bundle check.Tested
Windows 11, MSVC (VS 18), RelWithDebInfo, on
maind442851. Short GPU tests only (the d3d12 tests need a Vulkan device), no game boot.d3d12_com_test, new direct-list cases:ResourceBarrier(1, nullptr),Barrier(1, nullptr), and a group of each type with one barrier and no array (alone, and after a valid group) failClosewithE_INVALIDARG;ResourceBarrier(0, nullptr),Barrier(0, nullptr), a group with no barriers and no array, and a valid transition close withS_OK.d3d12_buffer_tiles_test(layer half):CopyTilesof a reserved buffer recorded in a bundle fails the bundle'sClose. The same call on a direct list is the existing case that follows.process_cmdline_test: the command line<temp folder>\*.lxwith two synthetic files there givesargc3 withexpand=1and 2 (the pattern as typed) withexpand=0, narrow and wide. A nullargcorargvfails.main'sd3d12_com.cppandprocess.cppand the new tests, all three fail:d3d12_comandprocess_cmdlinecrash (segfault on the null arrays and pointers),process_cmdlinealso reportsargc 2, want 3forexpand=1, andd3d12_buffer_tilesfails at the bundle'sClose.ctest -R "^(d3d12_com|d3d12_buffer_tiles|process_cmdline|d3d12_bundle|d3d12_bundle_forbidden|d3d12_texture_tiles|d3d12_mesh)$": 7/7 pass with the fix.scripts/check_no_game_data.py: clean.Not tested: the
run_entryrace has no test (it needs another thread to end the run before the game thread is scheduled). The change removes the stack pointer, so there is nothing left to race on. The calibration path needs a device without calibrated timestamps, which this one has.GPUs tested: profile M: NVIDIA GeForce RTX 4070 SUPER, 12 GB, desktop, driver 621.01, Windows 11
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code