Skip to content

shader: prove a graphics formatted load whose table pointer copy is in a block above - #3688

Merged
R0Y00 merged 2 commits into
R0Y00:mainfrom
Not-Saii:shader/graphics-formatted-pointer-copy
Dec 1, 2026
Merged

R0Y00 merged 2 commits into
R0Y00:mainfrom
Not-Saii:shader/graphics-formatted-pointer-copy

Conversation

@Not-Saii

@Not-Saii Not-Saii commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

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 an s_mov_b32 copy 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_copy walks 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 are image_sample_lz modifier d16 and v_readfirstlane_b32 requires a proven uniform source.

Tests

tests/startup_vertex_fetch_formats_check.py controls:

  • Changed control: the graphics control that expected a refusal for a pointer copy in a block above now expects the translation. It checks srv 0 buf table 0 0 in 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.
  • New negative control: one arm of an s_cbranch_scc0 writes the pointer copy again. It is refused with ... local table load.
  • Without the translator change, the positive control fails with formatted buffer load requires descriptor words proven in the entry block or a local table load.

Commit 9e77e6f4 (on main a3bfd019), Windows 11, Python 3.11, each exit 0:

python -B tests/startup_vertex_fetch_formats_check.py controls
python -B tests/startup_gfx2hlsl_compute_check.py
python -B tests/startup_compute_store_d16_x_check.py
python -B tests/startup_compute_store_format_xyzw_check.py
python -B tests/startup_gfx2hlsl_compute_spill_check.py
python -B tests/startup_gfx2hlsl_join_symbols_check.py
python -B tests/startup_gfx2hlsl_sgpr_spill_check.py
python -B tests/startup_mesh57_lane_spill_check.py
python -B tests/mesh_lane_spill_check.py
python -B tests/startup_gfx2hlsl_refusals_check.py
python -B tests/startup_buffer_format_word3_table_check.py
python -B tests/startup_stream_fetch_check.py
python -B tests/startup_compute_image_store_check.py
python -B tests/startup_pixel_image_store_check.py
python -B tests/startup_gfx2hlsl_heap_record_check.py
python -B tests/startup_mesh57_skeleton_check.py
python -B tests/docs_links_check.py

Not run or not covered

  • I did not run CMake, ctest, startup_vertex_fetch_formats_warp/_hardware or startup_mubuf_descriptor_*. No emitted HLSL shape changes, so the existing readbacks apply to the newly accepted programs unchanged.
  • High word: like the existing in-block copy path and the compute copy path, the block proof does not check that the copied pair's high word is 0. The predecessor proof from shader: prove formatted load descriptor words across a join #3486 does check it. The s_load handler 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_block is also used by spill_word_proven and by the two formatted store proofs. In graphics stages they now accept the same copy. Their checks above pass.
  • Overlap: shader: decode buffer FORMAT 47 (10_10_10_2 SSCALED) from hardware descriptors #3382 edits startup_vertex_fetch_formats_check.py at 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

Not-Saii and others added 2 commits December 1, 2026 02:43
…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 lukaslw-lab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_writers returns two writers, so formatted_pointer_copy returns None (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 (the index is None arm), 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 by formatted_pointer_reaches up to the copy.
    • The unchecked high word is already the rule on the in-block and compute paths, as the body says.

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.

@R0Y00
R0Y00 merged commit 1c63403 into R0Y00:main Dec 1, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants