shader: preserve StartInstanceLocation store in indexed_indirect_guard and add tests #3663
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3663
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3661"
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?
@Ammmae0x on GitHub · 2026-11-30 22:12 UTC · original
Ammmae0x:tests/startup-indexed-indirect-guard→main· +1120 −3 · 6 files · 3 commits · merged 2026-12-01 03:13 UTCRefs #1149, #2252.
Fixes two real Windows bugs found during WARP+NVIDIA verification, and adds D3D12
cs_5_0dispatch + boundary + configure-time HLSL mutation tests forx2w_startup::indexed_indirect_guard(src/startup_stubs/indexed_indirect_guard.h).1) FXC
cs_5_0dropsStore(24, start_instance). WithD3DCompile(..., "cs_5_0", flags=0)(as ind3d12_draw.inl),verified.Store(4, args.w); verified.Store4(8, args); verified.Store(24, start_instance); verified.Store(0, 1);hit an FXC optimizer bug and omittedStore(24, start_instance)from DXBC (store_rawemitted only offsets 0 and 8, never writing word 6), soverified[6]stayed0xDEADBEEFonvalid_u16_high_lowandvalid_u32_neg_base. Replaced with:verified.Store3(4, uint3(args.w, args.x, args.y));(root constant + count, instances)verified.Store3(16, uint3(args.z, args.w, start_instance));(start_index, base, start_instance)verified.Store(0, 1);This emits all 7 words (verified under D3DDisassemble
cs_5_0flags=0:store_raw u0.xyz, l(16)+store_raw u0.xyzw, l(0)).2)
startup_indexed_indirect_guard_arg_align_mutfailed to trip. In D3D12ByteAddressBuffer::Load4(arg_offset)ignores bits [1:0] (ld_rawreads atarg_offset & ~3, i.e. 0 whenarg_offset=2).dispatch()uploadedarg_wordsonly at offset 2, soLoad4(2)read{0x00030000, ...}(count > 4096) and dropping(arg_offset & 3)still refused.dispatch()now uploadsarg_wordsandstart_instanceatspec.arg_offset & ~3u(0), so the aligned-downLoad4(2)reads valid{3, 1, 0, 0}, the mutant accepts the draw (verified[0]=1) and is killed byWILL_FAIL TRUE. The Python model mirrors this withoffset & ~3inload()and the same aligned upload in its fixture.What landed (commit
2d813325, on top off019f0fb+78b8379d):src/startup_stubs/indexed_indirect_guard.h: the twoStore3writes above, with a comment pinning the FXC bug.tests/startup_indexed_indirect_guard_check.cpp:dispatch()uploads atarg_offset & ~3u; 2 valid draws (valid_u16_high_lowwithindex_offset = 2,valid_u32_neg_basewithbase = -2) with exact words0..6, and 10 refusals (refuse_arg_align,refuse_arg_oob,refuse_elem_size,refuse_index_align,refuse_count_boundswith counts 2, 4, 4098,refuse_instance_nonone,refuse_start_instance,refuse_neg_base_underflow,refuse_pos_base_overflow,refuse_vertex_oob). Supports<warp|hardware> [<case>], honorsXBOX2WINDOWS_ADAPTER, exits 77 when no hardware adapter is available, never skips WARP.tests/cmake/startup_indexed_indirect_guard.cmake: registers_warpand_hardwaretests (TIMEOUT 60,SKIP_RETURN_CODE 77) plus 5WILL_FAIL TRUEconfigure-time HLSL mutation controls (drop arg-align clause, drop start-instance clause, drop negative-base underflow clause, low-half-only u16 read, drop vertices clause).tests/startup_indexed_indirect_guard_meta_check.py+tests/checks/python-linux/startup_indexed_indirect_guard.txt: Pythonuint32model ofguard()verifying all cases and killing all 5 HLSL mutations locally (12 cases, 5/5 killed), now pinning theStore3lines, thearg_offset & ~3uupload, and theoffset & ~3load.docs/experiments/startup-indexed-indirect-guard.md: case and control notes, plus a Windows findings section for both bugs, including whyrefuse_neg_base_underflowuses aUINT_MAXvertex count and whyrefuse_count_boundsuses 4098 indices.Linux (on
2d813325): meta check passes (12 cases, 5/5 mutations killed),run_checks_parallel.py --from-dir tests/checks/python-linux73/73, form/docs/bidi pass (193 files/750 links, 2765 files),py_compilepasses,diff --checkclean,git merge-tree --write-tree origin/main HEADexits 0 (noupstreamremote in this clone;origin/mainisa3bfd019), zero personal paths in the diff.Windows Verification (
2d813325d7bf93ec6df710b51044d943e2a6e661)AI-assisted.
tests: add D3D12 guard and mutation tests for indexed_indirect_guard.hto shader: preserve StartInstanceLocation store in indexed_indirect_guard and add tests@lukaslw-lab on GitHub · 2026-12-01 02:42 UTC · original · approved these changes
Reviewed
2d813325by reading the diff; not built or run.Verdict: approve. The two
Store3writes produce the same seven-word record as before, and the new D3D12 check pins every word. No MUST, no SHOULD.src/startup_stubs/indexed_indirect_guard.h:41-43): word 1 is the base-vertex root constant, and words 2–6 areD3D12_DRAW_INDEXED_ARGUMENTS(count, instances, start index, base vertex, start instance). This matches the 24-byte command signature ind3d12_draw.inl:2609-2611and the oldStore/Store4/Storesequence.Store(0, 1)still comes last, so a refused draw leaves the count at 0.start_instance == 0, and the runtime writes into a fresh committed default-heap buffer per validation (d3d12_draw.inl:2620-2628), which D3D12 zero-fills. So word 6 was 0 in real runs either way. The fix removes the reliance on zero-fill, and the sentinel-filled test buffer is what exposed the dropped store.arg_offset & ~3uupload in the test is a fixture change only. It makes the aligned-downLoad4read a valid record, so the arg-align control can actually be killed. The guard keeps its own(arg_offset & 3)refusal.valid_u16_high_lowwithindex_offset = 2, so only the high-half read can tell them apart. No existing test or source besides the header changes.Tests:
startup_indexed_indirect_guard_checkproves the guard's 2 accepted draws word for word (including word 6 against a sentinel) and 10 refusals on WARP/hardware. The five*_mutcontrols prove each clause is needed. CI at this head: Linux ran the Python model. Theprfilter (CMakePresets.json) does not includestartup_indexed_indirect_guard*, so the D3D12 evidence is the author's WARP and RTX 4050 dev + release runs (7/7).