shader: refuse stale SCC reads after descriptor arithmetic #2297
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2305"
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 RavenCurseBurg on 2026-11-25T11:23:35Z.
Refs #2302, item 3.
A scalar ALU operation on a symbolic descriptor word can set SCC without emitting a runtime value for it. A later conditional select, move or branch could then silently consume an earlier comparison. The translator records the actual emitted SCC assignments and descriptor-derived writes. If a descriptor-derived flag can reach an SCC reader on any reachable path, translation reports the reader. A comparison that all such paths pass through makes the flag usable again. The traversal includes direct branches, proven calculated jumps and back edges.
Both the graphics and compute stages use this lowering. Their cache revisions advance together because a complete revision-9 manifest and bytecode would otherwise bypass translation. The runtime, offline key calculation and independent fixture keys use the updated revision.
Verification
5fa712ee,--refusals --jsonreported 8/8 clear and--pendingpublished all eight manifests. At this head, four stale reads produce the expected per-reader refusal and no manifest, and all four refreshed controls still publishuav 0 table 1 16. These are counts from synthetic requests.python -B tests/startup_gfx2hlsl_compute_check.pypassed. The committed controls also cover a skipped refresh, the second pass of a two-iteration loop, an unreachable descriptor operation, 64-bit selects and moves, immediate moves, and a saveexec that supplies a fresh flag. On the base the new check failed because it accepted the stale select.clang -cc1as). The upstream binary job usesllvm-mc-15.startup_gfx2hlsl*_check.py, the startup translator, compute requests, cache key consistency, documentation links and bidirectional-control checks. All passed.git diff --checkpassed.^startup_gfx2hlsl_compute_and the indirect draw fixture that produces the graphics cache key. I'll post the Windows results on this head.AI-assisted with Codex (GPT-6.2 Astra, xhigh).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T11:26:38Z.
Review: COMMENTED
Review of head
d73c12d6c37b5934470932641de4927cd14513ea(Linux only; no Windows run).Result: no P1, no P2.
What I checked:
descriptor_scc_readswalks direct branches, fall-through, back edges and skips proven calculated-PC instructions. A later emitted SCC write (scc_effect == 'emitted') clears the stale state, as the PR text says.shader-9->shader-10is consistent:tools/startup/gfx2hlsl.py(pipeline_key,compute_key),src/startup_stubs/d3d12_draw.inl:235,355,tests/startup_indirect_draw_indexed.cpp:235,tests/startup_compute_request_offline_check.py:33,docs/startup-runtime.md:192. No leftovershader-9outside docs history.set_exec_sccrefactor keeps the same emitted text for saveexec/wrexec and now records the SCC effect.Commands executed locally in the review worktree:
python3 -B tests/startup_gfx2hlsl_compute_check.py-> passedpython3 -B tests/startup_compute_request_offline_check.py-> passedpython3 tests/docs_links_check.py-> 18 files, 446 links, okpython3 tests/bidi_controls_check.py-> okgit diff --check origin/main...HEAD-> cleanMutations (reverted with
git checkout -- .):descriptor_scc_reads: the compute check fails (accepted, expected a refusal naming 'scc from descriptor data'). Killed.stale = stale or ...) so a later emitted SCC write no longer clears it: the compute check fails (a refreshed control is refused). Killed.Notes (nit):
reads_sccis keyed on name prefixes plussrc_scc; a future SCC-reading mnemonic (for examples_cmovk,s_absdiff-style carry readers) must be added there. A short comment pointing at the opcode list would help.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-25T11:28:51Z.
Added the LLVM AMDGPU opcode-table reference beside
reads_sccin3e750a37. The existings_cmovprefix already coverss_cmovk_i32; the updated compute fixture checks it both before and after a fresh comparison. Re-ran the compute controls, offline cache-key test and source hygiene check after the comment change.The Windows 2025 run at d73c12d6 built the runtime shim and indirect draw fixture. All 11 selected CTests executed and passed, including the translated indirect draw and the compute WARP controls. The WARP compute dispatches reported zero debug-layer warnings and errors. All three standard upstream jobs also passed at that head.
I also tested the accepted path through
--pendingand the generated CSO. After masking descriptor word 1, the shader compares the X group ID to 1 and stores the selected bit. WARP and a desktop RTX 4060 (32.0.15.9579, Windows 26100.9711) each matched 320/320 words over 12 groups. Flipping the expected predicate changed 288 data words on each adapter and preserved all 32 guard words. On the RTX, all five existing compute cases matched and all ten existing mutation controls produced their expected mismatches. The local renderer was built at59a05959; the raw-buffer dispatch code is identical to the reviewed head.