startup: check the null binding cause labels #1490
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1497"
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 R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-24T12:58:13Z.
Change
Refs #1149. This adds a device-free check for
src/startup_stubs/null_binding_cause.h.The header classifies why a translated draw bound a null descriptor.
d3d12_draw.inlcounts each null binding at the index given by itsNullCausevalue. Thex2w-rendertotals line ind3d12_xs_device.cppthen prints slots 0 to 4 under labels typed into its format string:entry,buffer,token,wrapper,dimension.The only test that reaches the header is
startup_null_views_<adapter>, throughtests/null_binding_cause_cases.h, and it counts causes by enum name. It cannot see which slot a cause lands in, and no test reads the totals. So:buffer_unreadableandunknown_token, leftstartup_null_views_warppassing, while the totals line would print buffer counts astokenand the reverse;null_cause_namesalso left it passing;none = 0failed it only through an out-of-bounds write, after 4.3 s.startup_null_cause_labelsincludes only the header. It has one fact set per cause, built the way the texture and buffer call sites build them, and checks each cause's slot and name. It then counts a frame in which the five causes occur 1, 2, 4, 8 and 16 times, plus valid bindings that add nothing. It formats the totals twice, once with the device's format string and once with labels fromnull_cause_names. Both must equal the hand-written linenull bindings 31 (entry 1, buffer 2, token 4, wrapper 8, dimension 16).startup_null_cause_labels_buffer_token_controlruns--mutate buffer-tokenand must fail (WILL_FAIL).The change is test, CMake and
docs/startup-runtime.md("Null bindings in translated draws") only. The CMake block followsstartup_null_views.Verification
Commit
93672b99(main) plus this change,devpreset (Debug), Windows 11 Pro build 26300.9974, MSVC 19.51.36260, Windows SDK 10.0.26100.0, WARP 10.0.26100.9818.tests/docs_links_check.py,tests/bidi_controls_check.pyandgit diff --checkpassed.Mutation probe
I applied each mutation to the header alone, rebuilt the affected targets, ran the tests, then reverted. None of this is committed.
startup_null_views_warpstartup_null_cause_labelsbuffer_unreadableandunknown_tokenswapped in the enumnone = -1changed tonone = 0null_cause_namestokenandwrapperswapped!f.texture && f.bound→f.boundfrom_table &&on the unknown-token line!token_magic→!token_knownfrom_table &&on the table-entry line!resource_wrapperreturnsdimension_mismatchThe three equivalent mutants are not pinned, because no input the device builds tells them apart. Textures always have
from_table=trueandbound=false,token_knownis only set together withtoken_magic, and vertex and root bindings have no table entry.Two notes for the reviewer:
src/would not be noticed. It catches mismatches inside the header: enum order, thenonevalue and the order of the names.null_cause_namesis not used insrc/today. It is checked here as the header's stated label table. If you would rather remove it, say so and I will drop that part.Checklist
AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T13:15:10Z.
Review: COMMENTED
Reviewed
7ba209aab55de98c07c2afe257ba353d3bd885f5(CMakeLists.txt,docs/startup-runtime.md,tests/startup_null_cause_labels_check.cpp).Audit
startup_null_cause_labels_checkverifiesx2w_local::null_cause_count == 5, checksnull_cause_names[0..4]against{"entry", "buffer", "token", "wrapper", "dimension"}, tests eachNullCauseclassification into slots0..4, and checks power-of-two per-slot totals in the formatted totals line.--mutate buffer-token(startup_null_cause_labels_buffer_token_control,WILL_FAIL TRUE) swaps the expectedbufferandtokenslots and fails as intended.src/startup_stubs/d3d12_xs_device.cpprather than driving the device log, so it guardssrc/startup_stubs/null_binding_cause.hdirectly rather than catching a format-string edit ind3d12_xs_device.cpp.docs/startup-runtime.mdis updated accurately and remains title-neutral.Checks
tests/docs_links_check.py(16 Markdown files, 334 links),tests/bidi_controls_check.py(1223 tracked files), andgit diff --checkall passed.--preset dev): builtstartup_null_cause_labels_check(3.10s);ctest --preset dev -R '^startup_null_(cause_labels(_buffer_token_control)?|views_warp)$' --no-tests=error— 3/3 passed (0.15s)./O2(--preset release): builtstartup_null_cause_labels_check(0.44s);ctest --preset release -R '^startup_null_(cause_labels(_buffer_token_control)?|views_warp)$' --no-tests=error— 3/3 passed (0.13s).