d3d12, process: null barrier arrays, CopyTiles in a bundle, calibration wait, entry thread argument, getmainargs expand (RT-COM-NULL-BARRIERS-ENTRY) #2522
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2522"
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 Tyrannys on 2026-11-28T00:26:17Z.
Claimed in the coordination issue as: RT-COM-NULL-BARRIERS-ENTRY (https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7230796479)
What and why
Item 4 of @kevincommits' finding in #1608 (https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7230381887). 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 #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
maind44285197. 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
Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-28T01:34:02Z.
Reviewed at head
d411fe9b4on Windows 11 (MSVC 202219.44) with dual-GPU Vulkan validation (LEONIDA_VK_VALIDATION=1, Vulkan SDK1.4.363.0).Verification
process_cmdline_test,d3d12_com_test,d3d12_buffer_tiles_test, andgta6rt.process_cmdline_test: passed.d3d12_com_test(LEONIDA_VK_VALIDATION=1): passed with 0 validation errors on both NVIDIA GeForce RTX 5080 (616.64) and AMD Radeon(TM) Graphics (25.10.30.02).d3d12_buffer_tiles_test(LEONIDA_VK_VALIDATION=1): passed with 0 validation errors on both RTX 5080 and AMD Radeon.Notes (non-blocking)
CopyTilesbundle rejection ahead of both paths, calibration wait before query read, passing the entry address by value to the thread proc, and honoring the wildcard expansion flag for both CRT widths all look sound.d3d12_com.cpp:633: checkinggroup[g].pGlobalBarriersfor all three barrier types works on the Windows pointer ABI, though reading the active union member selected bygroup[g].Typeavoids relying on inactive-union-member reads in standard C++.d3d12_com_test.cpp:365-370:EXPECT(!invalid_direct_call(...))passes if allocator/list creation fails or ifClose()returns any error other thanE_INVALIDARG; assertingS_OKdirectly on the positive controls would make those checks stricter.process_cmdline_test.cpp:237-251: the narrow wildcard check assumes the absolute temp path round-trips through the host ANSI code page (an ASCII relative pattern under the fixture directory avoids locale sensitivity).Approve.
AI-assisted review + local MSVC/dual-GPU verification.
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T07:36:22Z.
#2522 | head
d411fe9b4a(merged cleanly with main09c1539483) |ctest --test-dir runtime/build -C RelWithDebInfo -R "^(process_cmdline|d3d12_com|d3d12_buffer_tiles)$" --output-on-failure(LEONIDA_VK_VALIDATION=1) | red on main:process_cmdline_testfails (__getmainargs/__wgetmainargsignoreexpand=1) and crashes with0xC0000005on nullargc/argv;d3d12_com_testcrashes with0xC0000005onResourceBarrier(1, nullptr)/Barrier(1, nullptr);d3d12_buffer_tiles_testfails (bundle->Close() == E_INVALIDARGonCopyTilesin a bundle) | green on PR+main:3/3CTests pass (process_cmdline,d3d12_comin0.47s, andd3d12_buffer_tilesin1.41s) on RTX 3090 withLEONIDA_VK_VALIDATION=1(0Khronos validation errors);check_no_game_data.py0violations | Windows 11, RTX 3090 (610.88), Vulkan SDK 1.4.363.1 | AI-assisted: yesImported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-28T09:28:05Z.
Review: APPROVED
Reviewed the diff and tested merged onto
main(493867366) with Ninja Release (MSVC) andLEONIDA_VK_VALIDATION=1.The null barrier array guards, early
CopyTilesbundle rejection,VK_QUERY_RESULT_WAIT_BITon calibration readback, direct entry-point thread argument inrun_entry(removing the stack-frame race), and__getmainargs/__wgetmainargswildcard 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_validation1.4.363).AI-assisted (Antigravity, Gemini).
Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-11-29T00:46:58Z.
RUN (Windows 11, red/green)
Tested heads: PR head
d411fe9b4a3aab2a75dfbed4d6e4f01d758ef668(one commit ond44285197);mainat1bc055e6c2dedaa0de23ec79d8c4007c1dff1fb3.git merge-tree --write-tree main pr-2522merges cleanly.Machine: Windows 11 Pro 10.0.26300, MSVC 14.44 (VS 2022 Build Tools), RelWithDebInfo, Ninja, 8 jobs. GPU NVIDIA GeForce RTX 3090 24 GB, driver 621.40.
Commands (only the three test targets and their dependencies were built, not the whole runtime):
GREEN (PR head):
process_cmdline,d3d12_com,d3d12_buffer_tiles: 3/3 passed.RED (behavioural): PR head with only
runtime/shims/d3d12_com.cppandruntime/shims/process.cppput back to the parent commit's version, the three test files kept; rebuilt the same three targets and ran the same ctest: 0/3 passed.process_cmdline: SEGFAULT, and before the crash "FAIL __getmainargs(expand=1): argc 2, want 3" and the same for__wgetmainargs.d3d12_com: SEGFAULT (null barrier arrays read through).d3d12_buffer_tiles: FAILED, "line 126: bundle->Close() == E_INVALIDARG" (CopyTiles of a reserved buffer in a bundle).This matches the PR description. Not covered by a test, as the PR says: the
run_entrythread argument and the calibration wait. I ran only these three tests, not the other six in the PR's ctest list.Link check: merged into main
1bc055e6c, gta6rt.exe builds and links (RelWithDebInfo, MSVC 19.44); no new imports vs main.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T01:03:40Z.
Merged after enlight3d (Thib)'s red/green run (RUN, RTX 3090, driver 621.40, Windows 11: green with this PR, red without it, and
gta6rt.exestill links) and a re-check here: no conflict withmain106e2611b, same head as run,no-game-datagreen, and the only ctest failures in the Windows/macOS CI jobs are tests this diff does not touch (known onmainor Vulkan: vk_xdxr_postbuild_readback vk_bindless_dimensions d3d12_compile_pool xbox_present ).AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.