Repository navigation
shader: prove a graphics formatted load whose table pointer copy is in a block above - #3688
Conversation
…n a block above R0Y00#2461 let a compute formatted buffer load past the entry block accept a table load through an s_mov_b32 copy of a root table pointer made in a block above, when that copy is the last write to the pointer on every path to the load. Graphics stages kept the in-block rule. The proof (formatted_pointer_copy) walks the instruction graph and does not depend on the stage, so vertex and pixel stages now use it too. The fixture's graphics control that expected a refusal now expects the translation (srv binding and the FORMAT switch), and a negative control where one arm writes the pointer copy again stays refused by this proof. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… fixture The measured shape sets the high word of the copied pair to 0 before the table load; the positive control now does the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lukaslw-lab
left a comment
There was a problem hiding this comment.
Reviewed 9e77e6f4 by reading the diff; not built or run.
Verdict: approve. The removed gate was not doing any work. formatted_pointer_copy → descriptor_last_writers is a walk over the instruction graph that does not depend on the stage. #2461's own mutation table lists "the kind == 'cs' gate dropped" as surviving, because no fixture separated stages. No MUST.
- NIT The gate also covered the mesh stage (
kind == 'ms',gfx2hlsl.py:2550), so mesh programs now accept the same copy. The body and the doc line (experiments.md:623) name only vertex and pixel. Mentioning mesh there, or adding a one-line mesh control, would make that visible on the P0 path. - Checked, no finding:
- The new negative control does reach the new path. With a second copy on one arm,
descriptor_last_writersreturns two writers, soformatted_pointer_copyreturnsNone(gfx2hlsl.py:7836-7848) and the block proof refuses. It is not refused for another reason. - A copy reached by the entry value on some path still gets
None(theindex is Nonearm), and an unknown ('any') writer ends the walk on a non-s_mov_b32. - The only graphics-specific control transfer, the VS fetch
s_swappc_b64, is accepted only at offset 0 (gfx2hlsl.py:1389). That is before any pointer copy, so it cannot hide a write between the copy and the load. The source pointer is still checked byformatted_pointer_reachesup to the copy. - The unchecked high word is already the rule on the in-block and compute paths, as the body says.
- The new negative control does reach the new path. With a second copy on one arm,
Tests: the changed positive control proves a VS with s_mov_b32 s10, s8; s_mov_b32 s11, 0 in the entry block and the table load in the use block now translates (manifest srv 0 buf table 0 0, the FORMAT switch). The new negative control proves that a rewrite on one arm is refused. CI did not run either: startup_vertex_fetch_formats_controls is not in the Windows pr filter or in the Linux job's script list, so the author's local run is the only one.
Refs #3478 (item 3).
Change
A formatted buffer load (
buffer_load_format_*) placed after the entry block needs proof that its four descriptor words are the table's. The block proof (formatted_descriptor_from_block) accepts a table load in the same block as the use. #2461 extended it to a load made through ans_mov_b32copy of a root table pointer made in an earlier block, provided that copy is the last write to the pointer on every path. That extension was limited to compute (kind == 'cs'). Its PR says graphics "keep the previous rule", and its review thread gives no technical reason.formatted_pointer_copywalks the instruction graph and does not depend on the stage. This change removes the gate, so vertex and pixel stages follow the same copy. Compute behaviour, refusal texts and emitted HLSL/manifest shapes are unchanged.#3486 added the predecessor (join) proof for #3478 item 3. That proof covers a table load in an earlier block. The shape here is different: the table load is in the use block, and only the pointer copy sits in the entry block (
s_mov_b32 sLo, sTable;s_mov_b32 sHi, 0). In a local census of one run, every graphics and render-target-variant request refused with this message had this shape. With this change, all of them get past the proof. None translates fully yet: the next first refusals areimage_sample_lz modifier d16andv_readfirstlane_b32 requires a proven uniform source.Tests
tests/startup_vertex_fetch_formats_check.py controls:srv 0 buf table 0 0in the manifest and the FORMAT switch in the vertex HLSL, and the copied pair's high word is set to 0 as in the measured shape.s_cbranch_scc0writes the pointer copy again. It is refused with... local table load.formatted buffer load requires descriptor words proven in the entry block or a local table load.Commit
9e77e6f4(on maina3bfd019), Windows 11, Python 3.11, each exit 0:Not run or not covered
startup_vertex_fetch_formats_warp/_hardwareorstartup_mubuf_descriptor_*. No emitted HLSL shape changes, so the existing readbacks apply to the newly accepted programs unchanged.s_loadhandler treats a table pointer as 32 bits wide, so this is a pre-existing modelling limit, not one this change adds. Requiring the check here would also change compute behaviour.formatted_descriptor_from_blockis also used byspill_word_provenand by the two formatted store proofs. In graphics stages they now accept the same copy. Their checks above pass.startup_vertex_fetch_formats_check.pyat a different hunk. "Buffer load through a modified descriptor" in pixel stages is shader: lower pixel structured-to-raw buffer loads #3100's scope and is not touched here.🤖 Generated with Claude Code