Skip to content

shader: preserve proven 32-bit graphics table offsets across forward joins - #2507

Merged
tedin7 merged 32 commits into
R0Y00:mainfrom
RavenCurseBurg:shader/forward-table-pointers-reviewed
Nov 26, 2026
Merged

tedin7 merged 32 commits into
R0Y00:mainfrom
RavenCurseBurg:shader/forward-table-pointers-reviewed

Conversation

@RavenCurseBurg

@RavenCurseBurg RavenCurseBurg commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Part of #2463, item 2. The parent #2069 has landed. This PR adds the forward-join proof and its fixture in nine files against main.

A graphics shader can copy its 32-bit resource-table pointer, advance it by 32 bytes and read the descriptor after two control-flow paths meet. Translation previously refused that load even when both paths had the same table and byte offset. It now preserves the pointer in that case. A missing definition, conflicting offsets, unsupported arithmetic or a loop-carried advance still refuses. A 64-bit vertex-buffer table still requires its matching high word.

Verification

  • At 3f1dafcd, the nine-file tree equals the result of applying only the forward-join changes to main 8ecaa8ec, after shader: propagate descriptor pointers through s_add_u32/s_addc_u32 in gfx2hlsl (Part of #1723) #2069. All 90 host translator, fixture and documentation checks passed. LLVM 15 reassembled all 14 fixture programs. Two independent review mutations failed as intended, including a backward edge and a copied high word.
  • In a differential check of 350 seeded graphics programs, every accepted case (49) selected the expected resource, all 220 cases with multiple possible offsets were refused, and 81 cases were conservatively refused. A separate high-SGPR control resolved table byte 48 and checked four refusals when a path lost its valid descriptor or VCC.
  • The 14 Windows Server CTests on the previous integrated head passed, including both compiler paths, the parent’s SMEM readback, and the 320-word raw-store readback. On that build the Intel UHD 770, RTX 4060 and WARP each ran the fixture with both FXC and DXC. All 30 positive images matched. Swapping the table binding changed all 32 pixels in each of the other 30.

To run the public fixture, use python -B tests/startup_joined_table_pointer_check.py and ctest --preset dev --no-tests=error -V -R '^startup_joined_table_pointer_'. The GPU fixture uses source-built inputs and two R8 textures. The addressed table byte selects the texture, and the green channel records the root constant used by the branch.

AI-assisted with Codex (GPT-6.2 Astra, xhigh).

tedin7 and others added 11 commits November 25, 2026 11:55
A table or root pointer advanced by a literal offset now keeps its source and
byte offset, so a following s_load reads the advanced descriptor. A register
addend on a pointer is refused instead of silently keeping the old pointer.

Part of R0Y00#1723
…ad through a pointer advanced by an untracked offset
Track a literal table address across copies and forward paths only when the incoming resource and byte offset agree. Exercise the published manifest against two GPU resources and compare all 32 pixels, including the root constant used by the branches.

AI-assisted with Codex (GPT-6.2 Astra, xhigh).
@ChazY11

ChazY11 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Four mutations of the descriptor-pointer propagation: two caught, and the two survivors are a source kind and a direction the fixtures never build

Control modes run clean here, device-free

python -B tests/startup_gfx2hlsl_desc_ptr_prop_check.py
    complete out-of-place pair leaves the original high source untouched: ok
    startup_gfx2hlsl_desc_ptr_prop: ok
python -B tests/startup_joined_table_pointer_check.py
    Graphics table pointer joins: five resource bindings and six refusals matched

Five bindings and six refusals is a good ratio for a change whose claim is "only a proven pointer join is preserved" —
the refusal side is where that claim actually lives.

Mutations

mutation result
a pointer that carries an offset is accepted instead of refused caught (desc_ptr_prop)
forward_table_adds forced False (every pointer advance refused) caught (joined_table_pointer)
PTR64_SOURCES loses vbtab (('root', 'vbtab') → ('root',)) survived
forward_table_adds stops requiring every branch target to be forward survived

The caught pair is the safety-critical one. Refusing an offset-carrying descriptor pointer is the whole premise — an
unmodelled addend is exactly the case where the address is unknown — and making forward_table_adds false is the
conservative direction; both are asserted.

Survivor 1: no fixture uses a vbtab pointer pair

PTR64_SOURCES = ('root', 'vbtab')

vbtab is a real source — self.sym[0] = ('ptr', ('vbtab',)) / self.sym[1] = ('ptrhi', ('vbtab',)) at the vertex-buffer
table setup, and it feeds 'vb %d' in the lookup key at line 6442. But every case in the two new checks starts from
root. Dropping vbtab from the tuple changes nothing they see, so the vertex-buffer table's pointer arithmetic is
unconstrained even though it is the same code path.

Survivor 2: no fixture presents a back edge

# Forward edges reach each block in disassembly order. A back edge could
# repeat a pointer advance before the next table load.
self.forward_table_adds = (getattr(self, 'kind', None) in ('vs', 'ps') and bool(branches)
                           and all(target > pc for pc, target in branches))

That comment names the hazard precisely, and nothing tests it: removing all(target > pc …) leaves every check green.
The joined-table fixture does use branches — four of its cases are "joined at a branch target" — but all of them branch
forward, so the all(...) conjunct is never the reason a verdict differs.

A loop whose body advances a table pointer and then loads through it is the case: the second iteration's pointer would
be classified as forward-propagated when it is a repeat. One case with an s_branch to an earlier PC, containing an
s_add_u32 on the pointer pair, would pin it — and it should be a refusal, since the whole design is "preserve only
what is proven".

I am not claiming either survivor is a bug. PTR64_SOURCES reads correctly and the all(...) conjunct is the
conservative one. They are the two places where the code is stricter than any test, which means the strictness is
currently unverified.

Environment

Windows 11 build 26300; pure Python, no DXC, no adapter, no game files for the rows above. tools/startup/gfx2hlsl.py
is CRLF — patches need the \r\n→\n→write-back dance or the anchor silently misses.

AI-assisted.

…gation

Exercise the two surviving mutations reported on R0Y00#2507 using full source-built programs. AI-assisted with Codex (GPT-6.2 Astra, xhigh).
@RavenCurseBurg

Copy link
Copy Markdown
Contributor Author

Thank you for running the four mutations. I added three complete gfx1013 programs in d7475ca4 and reran the two surviving mutations separately on the integrated head 45e6bc6f. Both now fail the host test.

  • The vertex control reads through the original 64-bit VB table pair at byte 32 and publishes srv 0 buf vb 2. The negative version adds 16 to the low word, copies the original high word without its carry, and loads at byte 16. The translator refuses the incomplete pair. Removing vbtab from PTR64_SOURCES incorrectly publishes slot 2 and fails the new assertion.
  • The existing loop-carried case already has a back edge, but joining its carried value also rejects the mutation. The new loop runs twice and reloads the same base inside each iteration before the add. Removing the forward-edge check now incorrectly accepts it under this PR's forward-only policy and publishes table byte 32. With the guard intact the load refuses the untracked offset.

The host test now checks six bindings and eight refusals. LLVM 15 reassembled all fourteen sources byte-for-byte. The 350-program differential check and 80 translator, fixture and documentation checks passed. I also integrated main's vertex raw-store support from #2570 and resolved the conflict in the shared load-provenance comment. The exact-head Windows run is underway.

I’m keeping the PR in draft. The parent author’s update says they plan to reopen and retest #2069 after the test-speed work.

@Makto94

Makto94 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Independent hardware run at head e68150dd (build exit code 0). The PR body reports an RTX 4060 run; this adds a second NVIDIA GPU.

Environment: NVIDIA GeForce RTX 3070 Ti, driver 32.0.16.2101 (NVIDIA 621.01) and Windows 11 Pro build 26300.9974 as reported by the system, dev preset (MSVC). The runs were serial (-j1).

Command: ctest --preset dev --no-tests=error -j1 -V -R '^startup_(joined_table_pointer_.*|gfx2hlsl_desc_ptr_prop)$'

Result: 6/6 passed, 0 failed (cpu, desc_ptr_prop, fxc_warp, dxc_warp, fxc_hardware, dxc_hardware). 0 capability skips (77).

Each draw test prints 10 table byte lines (for example fxc hardware table byte 0, 0 pixels changed from the source expectation and fxc hardware table byte 32, 32 pixels changed from the source expectation). The lines of the WARP and hardware tests are identical for FXC and for DXC (diff, after normalizing the backend name).

In the ctest log of the two _hardware tests, the only line that names an adapter is adapter=Microsoft Basic Render Driver driver=10.0.26100.9818 (5 times per test). It comes from the consumer call without a backend. The script captures the hardware calls, so they do not appear there.

To identify the adapter, I ran tests/startup_joined_table_pointer_check.py directly with hardware for each compiler, under a small local wrapper that prints the adapter line of every captured hardware call: 10 lines adapter=NVIDIA GeForce RTX 3070 Ti driver=32.0.16.2101 for FXC and 10 for DXC. The table byte lines of the FXC run match test 1111. The fixture does not print the debug layer state.

The diff also changes source files of tests registered before this PR. I ran the tests whose names match those files. Command: ctest --preset dev --no-tests=error -j1 -V -R '^startup_(smem_address_(controls|warp|hardware)|stream_draw_(warp|hardware)|address_srv_(warp|hardware))$'. Result: 7/7 passed, 0 failed, 0 skips (77). startup_stream_draw_hardware prints 2 adapter=NVIDIA GeForce RTX 3070 Ti lines and 2 adapter=Microsoft Basic Render Driver lines; startup_address_srv_hardware prints 1 of each. startup_smem_address_hardware does not print an adapter line.

This run covers NVIDIA and WARP only. Not covered: any test outside the two filters above.

@RavenCurseBurg
RavenCurseBurg marked this pull request as ready for review November 26, 2026 00:12

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review of head 3f1dafc (0 behind main, GitHub CI green).

Code read: tools/startup/gfx2hlsl.py only lets s_add_u32 carry a 32-bit table pointer across branches when every branch in the stage is forward (forward_table_adds, vs/ps only). Unknown byte offsets and sums above 0xfffff are refused. The legacy added marker no longer claims a single value. The CMake and workflow wiring matches the sibling join/desc-ptr tests. No other open or merged PR covers this slice (#2069 is the parent, #2466 is the exec-join sibling).

Commands run locally on Linux:

  • python3 -B tests/startup_joined_table_pointer_check.py: passed (6 bindings, 8 refusals).
  • python3 -B tests/startup_gfx2hlsl_desc_ptr_prop_check.py and tests/startup_gfx2hlsl_join_symbols_check.py: passed.
  • python3 tests/docs_links_check.py, python3 tests/bidi_controls_check.py, git diff --check origin/main...HEAD: clean.
  • Mutation 1: forward-only check relaxed so backward edges pass: the test fails ("advance inside a backward loop was accepted").
  • Mutation 2: accumulated-offset overflow check removed: the test fails ("offset overflow was accepted").

The GPU fixture (R8 texture selected by table byte, FXC and DXC, readback of pixels) is the real-readback guard; I did not run it here. The Win2025 WARP run follows separately.

AI-assisted; commands listed were executed locally.

@tedin7

tedin7 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

Win2025 WARP receipt for head 3f1dafc (up to date with main); targeted run of the new joined-table tests plus sibling desc-ptr/join checks.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 3f1dafcd5d67b45d17fb8b66e51fb4213aab8e6a:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target startup_stream_consumer -- -j 2): 2.31s (configure 0.00s)
    • Test (ctest --preset dev -R 'startup_joined_table_pointer|startup_gfx2hlsl_desc_ptr_prop|startup_gfx2hlsl_join_symbols|startup_stream_consumer' --parallel 4 --no-tests=error --output-on-failure): 11/11 passed (6.65s: startup_gfx2hlsl_join_symbols_controls 0.45s, startup_gfx2hlsl_join_symbols_folded_warp 0.45s, startup_gfx2hlsl_join_symbols_warp 0.66s, startup_gfx2hlsl_desc_ptr_prop 0.18s, startup_gfx2hlsl_join_symbols_hardware 0.66s, startup_joined_table_pointer_cpu 0.26s, startup_gfx2hlsl_join_symbols_folded_hardware 0.55s, startup_joined_table_pointer_fxc_warp 5.08s, startup_joined_table_pointer_dxc_hardware 4.82s, startup_joined_table_pointer_dxc_warp 5.20s, startup_joined_table_pointer_fxc_hardware 5.56s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target startup_stream_consumer -- -j 2): 6.66s (configure 0.00s)
    • Test (ctest --preset release -R 'startup_joined_table_pointer|startup_gfx2hlsl_desc_ptr_prop|startup_gfx2hlsl_join_symbols|startup_stream_consumer' --parallel 4 --no-tests=error --output-on-failure): 11/11 passed (6.31s: startup_gfx2hlsl_join_symbols_controls 0.37s, startup_gfx2hlsl_join_symbols_folded_hardware 0.39s, startup_gfx2hlsl_join_symbols_hardware 0.54s, startup_gfx2hlsl_join_symbols_warp 0.57s, startup_gfx2hlsl_desc_ptr_prop 0.16s, startup_joined_table_pointer_cpu 0.18s, startup_gfx2hlsl_join_symbols_folded_warp 0.40s, startup_joined_table_pointer_dxc_warp 4.92s, startup_joined_table_pointer_dxc_hardware 4.83s, startup_joined_table_pointer_fxc_warp 5.30s, startup_joined_table_pointer_fxc_hardware 5.36s)
  • Windows Python checks: tests/mesh_heap_sampler_check.py ok (1.1s), tests/startup_buffer_address_check.py ok (0.8s), tests/startup_buffer_format_word3_table_check.py ok (0.1s), tests/startup_compute_request_offline_check.py ok (0.7s), tests/startup_compute_store_format_xyzw_check.py ok (0.4s), tests/startup_compute_translate_check.py ok (0.3s), tests/startup_flat_param_check.py ok (0.2s), tests/startup_gfx2hlsl_add_sub_co_check.py ok (0.2s), tests/startup_gfx2hlsl_add_sub_co_ci_check.py ok (0.2s), tests/startup_gfx2hlsl_bit_alu_check.py ok (1.2s), tests/startup_gfx2hlsl_capture_check.py ok (1.7s), tests/startup_gfx2hlsl_cmp16_check.py ok (0.5s), tests/startup_gfx2hlsl_compare_dst_check.py ok (0.1s), tests/startup_gfx2hlsl_compute_check.py ok (0.7s), tests/startup_gfx2hlsl_cselect_mask_check.py ok (0.1s), tests/startup_gfx2hlsl_cvt_alu_check.py ok (0.3s), tests/startup_gfx2hlsl_cvt_off_f32_i4_check.py ok (0.3s), tests/startup_gfx2hlsl_cvt_pk_int16_check.py ok (0.4s), tests/startup_gfx2hlsl_f32_lg_check.py ok (2.1s), tests/startup_gfx2hlsl_f32_nan_check.py ok (8.9s), tests/startup_gfx2hlsl_fma_mix_check.py ok (0.2s), tests/startup_gfx2hlsl_getpc_refusal_check.py ok (0.1s), tests/startup_gfx2hlsl_handler_arity_check.py ok (0.1s), tests/startup_gfx2hlsl_image_arity_check.py ok (0.1s), tests/startup_gfx2hlsl_image_get_lod_check.py ok (0.3s), tests/startup_gfx2hlsl_int_med3_check.py ok (0.2s), tests/startup_gfx2hlsl_interp_p2_hi_check.py ok (0.3s), tests/startup_gfx2hlsl_join_symbols_check.py ok (0.3s), tests/startup_gfx2hlsl_loop_constants_check.py ok (0.1s), tests/startup_gfx2hlsl_mask_data_check.py ok (0.1s), tests/startup_gfx2hlsl_mask_overwrite_check.py ok (0.1s), tests/startup_gfx2hlsl_operand_count_check.py ok (0.5s), tests/startup_gfx2hlsl_pack_absdiff_check.py ok (4.2s), tests/startup_gfx2hlsl_pack_b32_f16_check.py ok (0.2s), tests/startup_gfx2hlsl_readfirstlane_recompute_check.py ok (0.2s), tests/startup_gfx2hlsl_readfirstlane_uniform_check.py ok (0.2s), tests/startup_gfx2hlsl_refusals_check.py ok (1.0s), tests/startup_gfx2hlsl_root_check.py ok (1.1s), tests/startup_gfx2hlsl_sad_check.py ok (0.5s), tests/startup_gfx2hlsl_saveexec_same_reg_check.py ok (0.1s), tests/startup_gfx2hlsl_scalar_arity_check.py ok (0.4s), tests/startup_gfx2hlsl_scalar_brev_fold_check.py ok (0.3s), tests/startup_gfx2hlsl_scalar_m0_check.py ok (0.2s), tests/startup_gfx2hlsl_scalar_table_arity_check.py ok (0.5s), tests/startup_gfx2hlsl_sdwa_cvt_check.py ok (0.4s), tests/startup_gfx2hlsl_sgpr_spill_check.py ok (0.3s), tests/startup_gfx2hlsl_shift64_check.py ok (0.3s), tests/startup_gfx2hlsl_sload_const_offset_check.py ok (0.1s), tests/startup_gfx2hlsl_smem_offset_check.py ok (0.1s), tests/startup_gfx2hlsl_sop2_complement_check.py ok (9.7s), tests/startup_gfx2hlsl_sopk_accum_check.py ok (1.4s), tests/startup_gfx2hlsl_sopk_signext_check.py ok (0.2s), tests/startup_gfx2hlsl_swap_check.py ok (0.6s), tests/startup_gfx2hlsl_vopc_sdwa_check.py ok (6.3s), tests/startup_gfx2hlsl_waitcnt_depctr_check.py ok (0.1s), tests/startup_gfx2hlsl_watch_check.py ok (2.7s), tests/startup_image_2d_array_check.py ok (0.3s), tests/startup_image_3d_check.py ok (0.2s), tests/startup_image_gather_lz_check.py ok (0.8s), tests/startup_image_load_d16_check.py ok (1.6s), tests/startup_image_sample_a16_check.py ok (0.4s), tests/startup_image_sample_b_check.py ok (0.3s), tests/startup_image_sample_c_check.py ok (0.3s), tests/startup_image_sample_l_check.py ok (0.3s), tests/startup_image_sample_lod_check.py ok (1.0s), tests/startup_inline_sampler_check.py ok (0.3s), tests/startup_mesh57_loop_refusal_check.py ok (0.3s), tests/startup_mesh57_skeleton_check.py ok (0.8s), tests/startup_run_ps1_check.py ok (19.0s), tests/startup_run_sh_check.py skipped (0.1s), tests/startup_sampler_heap_check.py ok (0.2s), tests/startup_shader_cache_rekey_check.py ok (4.0s), tests/startup_smem_address_check.py ok (0.3s), tests/startup_stream_fetch_check.py ok (0.3s), tests/startup_stream_interface_check.py ok (0.4s), tests/startup_translator_check.py ok (0.7s)
  • sccache: 10/47 hits; wall 109.1s

AI-assisted; commands listed were executed locally.

@tedin7
tedin7 merged commit 9260908 into R0Y00:main Nov 26, 2026
5 checks passed
SimSalabimse added a commit to SimSalabimse/Xbox2Windows that referenced this pull request Nov 26, 2026
… (#17)

* shader: add offset, short-read, and regular-file guards in sgd5_effects with CLI suite (R0Y00#2608)

Co-authored-by: tedin7 <110300616+tedin7@users.noreply.github.com>

* startup: count new view records by slot behind an opt-in census (R0Y00#2613)

X2W_D3D12_VIEW_CENSUS=1 counts new distinct view records by device slot
and logs the record vector capacity and hash bucket count before an
insertion that is expected to grow either. Record identity, ids and
descriptor binding do not change.

Refs R0Y00#1199

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>

* startup: lower v_pack_b32_f16 with op_sel and neg/abs in gfx2hlsl (R0Y00#2475)

* startup: lower v_pack_b32_f16 with op_sel and neg/abs in gfx2hlsl

D[15:0] = S0.f16, D[31:16] = S1.f16 (AMD RDNA 2 ISA, VOP3
V_PACK_B32_F16). op_sel[i] selects the high half of source i (LLVM 15:
VOP3_OPSEL); neg and abs act on bit 15 of the selected half, abs first.
The halves are copied as bits, as pixel_aot lowers the same instruction;
no binary16 denormal flush or NaN quieting is modelled (assumed).
Register sources only: an inline float constant on a binary16 operand
is a binary16 value. A destination op_sel bit and clamp are refused.

Test: tests/startup_gfx2hlsl_pack_b32_f16_check.py evaluates the emitted
expression for every op_sel x abs x neg combination over sample register
pairs against a bit reference (2304 cases), plus an SGPR source.
Negative controls: swapped halves and neg-before-abs are caught by the
reference; without the handler the instruction is refused, as on main.

* gfx2hlsl: explain the low/high half reads and the strict op_sel spelling in v_pack_b32_f16 (comments only)

* tests: verify packed binary16 output words on D3D12

---------

Co-authored-by: Royoo <3230853833@qq.com>
Co-authored-by: tedin7 <110300616+tedin7@users.noreply.github.com>

* cpu: lower 16 VEX.256 AVX2 cross-lane extend and dword/qword unpack forms (R0Y00#2614)

* cpu: lower 32/64-bit BMI2 BZHI, MULX, PDEP, and PEXT in cpu_bmi2_bit_aot (R0Y00#2621)

* pe: sort package scan and harden CLI path guards in pe_package_preflight with CLI suite (R0Y00#2609)

Co-authored-by: tedin7 <110300616+tedin7@users.noreply.github.com>

* shader: harden rdna_cvt_pk_u8 CLI validation and atomic writes with CLI suite (R0Y00#2619)

* ffx: add upfront path guards and atomic writes to ffx_working_set_delta with CLI suite (R0Y00#2616)

* startup: refuse a lane mask read as data by v_mov_b32 and v_cndmask_b32 (R0Y00#2623)

A lane-mask register (a compare result, vcc_lo, exec_lo, a saved EXEC
copy) holds only the current lane's bit in the one-lane model, while
RDNA 2 reads the whole mask word when the register is a data operand.
v_cndmask_b32 (both data operands) and v_mov_b32 (plain, e64 and SDWA
DWORD) took such a register through u()/u_src and emitted the lane bit.
They now refuse it, after stripping the source modifiers; the lane
select of v_cndmask is unchanged.

Tests that moved a mask with v_mov_b32 first now expect the new refusal,
or read the mask as a lane select instead so they still reach the
refusal they test. The SDWA check that accepted a whole-mask move now
expects a refusal.

AI-assisted.

* tests: reuse the compute pipeline across descriptor-format references (R0Y00#2615)

* tests: run compute store references on a shared renderer device

* tests: compare the descriptor fixture using one device for its reference cases

* tests: use one root signature and compute pipeline for the reference batch

* tests: retain case labels and 320-word diagnostics in the shared compute run

---------

Co-authored-by: RavenCurseBurg <360931527+RavenCurseBurg@users.noreply.github.com>
Co-authored-by: tedin7 <110300616+tedin7@users.noreply.github.com>

* runtime: add upfront CLI guards and atomic writes to bink_heap_aot with CLI suite (R0Y00#2627)

* ci: harden coverage_svg validation and atomic writes with CLI suite (R0Y00#2617)

Co-authored-by: tedin7 <110300616+tedin7@users.noreply.github.com>

* shader: classify RDNA2 permlane operations as cross-lane (R0Y00#2628)

- Preserve ordinary vector ALU classification and translator refusal.
- Exercise the authored encodings and dashboard categories.

Co-authored-by: tedin7 <110300616+tedin7@users.noreply.github.com>

* d3d12: do not wrap large allocations for unplaced memory SRVs (R0Y00#2611)

An unplaced buffer memory SRV (device slot 70, R0Y00#2395) wrapped the whole
allocation holding the view with OpenExistingHeapFromAddress. A 6 KiB view
in a ~2.15 GiB title startup block wrapped the block; afterwards each
VirtualQuery over it took seconds and DirectStorage requests stalled for
~120 s. Wrap only allocations up to the existing 256 MiB span limit (size
from one region-information call); larger ones take the upload copy.

Co-authored-by: lukaslw-lab <291379150+lukaslw-lab@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* cpu: lower VEX.128/256 AVX horizontal and addsub FP ops in cpu_avx_horiz_fp_aot (R0Y00#2629)

* script: add archive file and ASCII state guards to script_state_probe with CLI suite (R0Y00#2620)

Co-authored-by: tedin7 <110300616+tedin7@users.noreply.github.com>

* tests: use a portable negative record offset in the SGD5 CLI fixture (R0Y00#2632)

* shader: lower image_sample_d and document image_sample_c_d refusal in gfx2hlsl (Part of R0Y00#1723) (R0Y00#2082)

* feat: lower image_sample_d to SampleGrad in gfx2hlsl

Part of R0Y00#1723. 2D, 2D array and 3D gradient samples; image_sample_c_d is refused by name (needs SM 6.8).

* test: register startup_image_sample_d in CMake

Part of R0Y00#1723.

* startup: keep the guest LOD cap for image_sample_d and document the form in gfx2hlsl

* test: WARP and hardware readback for image_sample_d against a CPU reference

* tests: build the implicit Sample negative control with two arguments

---------

Co-authored-by: Royoo <3230853833@qq.com>

* tests: add source-built mesh57 loop refusal fixture (R0Y00#2413 T6) (R0Y00#2622)

Prove tip translate_mesh57 refuses a back-edge outside the accepted
group-memory exchanges by the named loop reason, with a mutant that
drops the back-edge and an exact-string oracle.

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
Co-authored-by: tedin7 <110300616+tedin7@users.noreply.github.com>

* shader: propagate descriptor pointers through s_add_u32/s_addc_u32 in gfx2hlsl (Part of R0Y00#1723) (R0Y00#2069)

* fix: carry descriptor pointers through s_add_u32/s_addc_u32 in gfx2hlsl

A table or root pointer advanced by a literal offset now keeps its source and
byte offset, so a following s_load reads the advanced descriptor. A register
addend on a pointer is refused instead of silently keeping the old pointer.

Part of R0Y00#1723

* shader: refuse descriptor pointer advances across branches and detached s_addc_u32 in gfx2hlsl (Part of R0Y00#1723)

* shader: keep the pointer-advance bookkeeping safe for stages without branch state (Part of R0Y00#1723)

* fix: keep the branch-join refusal for pointer adds in branching shaders

* fix: require the matching high-word add before folding an advanced descriptor pointer

* fix: advance 32-bit table pointers without a high word and judge the high operand by content

* fix: keep descriptor pointer pair open until its matching s_addc_u32

* fix: let the descriptor pointer pair pass translate's SCC check, add WARP readback case

* fix: refuse an untracked-offset pointer as a descriptor, run the pointer check in Linux CI

* fix: refuse a root pointer load whose high word was overwritten

* Revert "fix: refuse a root pointer load whose high word was overwritten"

This reverts commit 0f226c5.

* startup: re-key slot 57 mesh requests in shader_cache_rekey.py (R0Y00#2634)

shader_cache_rekey.py re-keyed graphics, RTV and slot 67 compute requests
and only counted slot 57 mesh requests. mesh57_key hashes the request
files under a versioned prefix, so after a revision that changes it a
kept cache lost every slot 57 request. The tool now recomputes that key
with mesh57_key and copies .ps57, .root and the .m57 ready marker under
the new name, with the rules the other kinds follow: everything read
first, nothing written on a missing or unreadable part, temporary name
then rename, an existing target left alone. Slot 86 is still only
counted.

AI-assisted.

* shader: extract main(argv), bounds checks, and struct/zlib guards in shader_census with CLI suite (R0Y00#2437)

* shader: extract main(argv), bounds checks, and struct/zlib guards in shader_census with CLI suite

* tests: accept Python 3.14+ argparse message in shader_census_cli_check

---------

Co-authored-by: tedin7 <110300616+tedin7@users.noreply.github.com>

* startup: invalidate slot 35 tables when the compute view heap changes (R0Y00#2636)

Track ordinary and oversized compute view heaps separately from the graphics lookup. Keep the table when the same heap is rebound and clear it on changes or unset. Cover the recorder in the CPU checks.

Co-authored-by: chasegrindy <302242206+chasegrindy@users.noreply.github.com>

* tests: run heap-view load references in one batch per compute shader (R0Y00#2635)

Co-authored-by: RavenCurseBurg <360931527+RavenCurseBurg@users.noreply.github.com>
Co-authored-by: tedin7 <110300616+tedin7@users.noreply.github.com>

* shader: lower s_bitset0/1_b32 in gfx2hlsl (R0Y00#2023 Item J) (R0Y00#2638)

* shader: lower s_bitset0/1_b32 in gfx2hlsl (R0Y00#2023 Item J)

Port the pixel_aot bit set/clear SOP1 forms so ordinary vertex and pixel
pipelines that only need an in-place scalar bit update stop refusing at
s_bitset1_b32. SCC stays unchanged; lane masks and descriptor SGPRs refuse.

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>

* test: pin sopk descriptor-refusal mutation to sopk-only raise

s_bitset0/1_b32 reused the plain-scalar sym allow-list line, so the
sopk_accum mutant needle was no longer unique. Match the sopk raise that
formats with `base` instead.

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>

* startup: implement command-list slot 14 Dispatch (Part of R0Y00#870) (R0Y00#1974)

* feat: record command-list slot 14 Dispatch on the desktop list

Part of R0Y00#870. Forward Dispatch only with a desktop compute pipeline and root
bound and group counts within 65535 per axis; refuse otherwise.

* startup: refuse Dispatch under a compute root with unforwarded arguments, document slot 14

* startup: gate Dispatch on bound compute root SRVs and a pipeline built against the bound root

Slot 43 clears a parameter's binding when a replacement is rejected, slot 33 clears all bindings, and the compute pipeline records its root so a mismatched pair is refused.

* fix: pass pipeline root out-param in slot86 mesh cached pipeline build

* tests: drive native slot 14 Dispatch through the stand-in

startup_list_dispatch_native creates a guest device on a desktop
adapter (WARP or hardware, debug layer on when installed) and drives
command-list slots 86, 25, 33, 43, 148, 14, 9 and 139 of the stand-in.
Each refused case must write exactly one
"x2w-render Dispatch(x, y, z) refused: <reason>" line, with the
expected reason, to X2W_TRAP_LOG:

- a root SRV never set;
- a rejected (foreign address) or misaligned slot 43 replacement after
  a valid one;
- a root changed and changed back without a new slot 43;
- a pipeline built against another root;
- a root with a descriptor table, and a root with a static sampler;
- an unset root SRV with zero groups;
- 65536 groups on X;
- a Dispatch on the closed list;
- a Dispatch after Reset without new bindings.

A forwarded case must write no line. The fixture wraps a
pipeline-statistics query around every slot 14 call on an open list,
recorded on the underlying desktop list: CSInvocations must be 4 per
group when forwarded and 0 when refused. The fully bound call is
recorded alone and read back first, so a slot 14 that records nothing
fails on its count. All three recordings are executed to a fence and
the debug layer must report no error.

The skip_srv control drops slot 43 from the first forwarded case and
must report it as refused. Each of these one-line changes to
d3d12_xs_device.cpp makes the WARP and hardware tests fail: the
refusal branch never taken, compute_srv_bound not cleared by slot 33,
the bit not cleared by a rejected slot 43, compute_root_has_arguments
forced false, root_matches_pipeline forced true, and the slot 14
registration removed.

The docs section now names the device fixture and corrects the
sentence on which compute root-argument slots have handlers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: list_dispatch header names slot 43 as forwarded

---------

Co-authored-by: The Void <mrdominogrm@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Royoo <3230853833@qq.com>

* startup: implement command-list slots 37 and 39 root constants and views (Part of R0Y00#870) (R0Y00#1975)

* startup: record SetComputeRoot32BitConstant(s) (list slots 37, 39)

Compute root constants are kept per list next to the graphics ones, in a shared 16 x 8 word store that refuses parameter >= 16 and offset >= 8. A new compute root signature clears them.

* fix: track which compute root constant words were set; drop slot 40 claim

* tests: run both PowerShell shells in parallel in startup_run_ps1 (R0Y00#2487)

* shader: preserve proven 32-bit graphics table offsets across forward joins (R0Y00#2507)

* fix: carry descriptor pointers through s_add_u32/s_addc_u32 in gfx2hlsl

A table or root pointer advanced by a literal offset now keeps its source and
byte offset, so a following s_load reads the advanced descriptor. A register
addend on a pointer is refused instead of silently keeping the old pointer.

Part of R0Y00#1723

* shader: refuse descriptor pointer advances across branches and detached s_addc_u32 in gfx2hlsl (Part of R0Y00#1723)

* shader: keep the pointer-advance bookkeeping safe for stages without branch state (Part of R0Y00#1723)

* fix: keep the branch-join refusal for pointer adds in branching shaders

* fix: require the matching high-word add before folding an advanced descriptor pointer

* fix: advance 32-bit table pointers without a high word and judge the high operand by content

* shader: keep 32-bit table offsets at agreeing forward graphics joins

Track a literal table address across copies and forward paths only when the incoming resource and byte offset agree. Exercise the published manifest against two GPU resources and compare all 32 pixels, including the root constant used by the branches.

AI-assisted with Codex (GPT-6.2 Astra, xhigh).

* fix: keep descriptor pointer pair open until its matching s_addc_u32

* tests: cover vertex-table carries and backward edges in pointer propagation

Exercise the two surviving mutations reported on R0Y00#2507 using full source-built programs. AI-assisted with Codex (GPT-6.2 Astra, xhigh).

* fix: let the descriptor pointer pair pass translate's SCC check, add WARP readback case

* fix: refuse an untracked-offset pointer as a descriptor, run the pointer check in Linux CI

* fix: refuse a root pointer load whose high word was overwritten

* Revert "fix: refuse a root pointer load whose high word was overwritten"

This reverts commit 0f226c5.

---------

Co-authored-by: tedin7 <tommasoderosa94@gmail.com>
Co-authored-by: RavenCurseBurg <360931527+RavenCurseBurg@users.noreply.github.com>

* tests: split four long CPU checks into parallel ctest cases (R0Y00#2489)

* tests: split four long CPU checks into parallel ctest cases

* docs: say in the file headers that CTest runs the parts and check runs them all

* fix: let the no-path x87 aggregate modes parse without file arguments

* shader: lower s_abs_i32 in gfx2hlsl (Part of R0Y00#1723) (R0Y00#2640)

* shader: lower s_abs_i32 in gfx2hlsl (R0Y00#1723)

Port the pixel_aot signed absolute SOP1 so ordinary pipelines that only need
|S0| stop refusing. SCC is the nonzero test of the result; INT_MIN stays.
Lane masks and descriptor words are refused. CPU fixture with a negative control.

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>

* test: pin sopk descriptor-refusal mutation to sopk-only raise

s_bitset0/1_b32 reused the plain-scalar sym allow-list line, so the
sopk_accum mutant needle was no longer unique. Match the sopk raise that
formats with `base` instead.

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>

* test: add D3D12 WARP dispatch readback for s_abs_i32

Mirror the R0Y00#2639 / pack_absdiff UAV dump pattern. Cover INT_MIN, -1, 0,
a positive word, SCC, and an SCC-dependent branch on the adapter.

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>

* build: register s_abs_i32 WARP/hardware dispatch ctests

Wire startup_gfx2hlsl_s_abs_dispatch_{warp,hardware} to the new
UAV-readback mode so Windows CI and Sander can run the fixture.

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
Co-authored-by: Royoo <3230853833@qq.com>

* startup: accept the slot 57 count exchange entered under a v_cmpx-narrowed EXEC (Part of R0Y00#2413) (R0Y00#2643)

* startup: accept the slot 57 count exchange entered under a v_cmpx-narrowed EXEC

The region before the count exchange may end with s_mov_b64 exec, -1, a
v_cmpx_gt_u32_e32 or v_cmpx_lt_u32_e32 of an SGPR against the proven
thread index, and an s_cbranch_execz to the exchange's first s_barrier.
The skipped block may hold lane-only instructions and scalar ALU whose
results are dead at the exchange: no SGPR it writes is read from the
exchange on, and SCC is rewritten by the exchange's s_cmp_eq_i32 before
any read. Both count-exchange arms replace EXEC before lane-dependent
work, and the HLSL barrier runs for every thread. Branches into the
skipped block, other compare sources, scalar loads and other execz
blocks stay refused.

AI-assisted.

* startup: accept any defined operands in the slot 57 count-entry compare

The entry before the count exchange no longer requires the compare to use
the thread index. The skipped block only leaves lane-predicated VGPR
writes and scalar results that are dead at the exchange, and both exchange
arms replace EXEC, so any per-lane EXEC from v_cmpx_gt_u32_e32 or
v_cmpx_lt_u32_e32 gives the same visible result for a per-lane skip as for
a per-wave skip. Each VGPR operand must be defined for every lane (not an
entry value or left stale by an exchange); SGPRs and constants are taken.

AI-assisted.

* tests: select the hardware adapter for indirect Dispatch readbacks (R0Y00#2652)

Co-authored-by: RavenCurseBurg <360931527+RavenCurseBurg@users.noreply.github.com>

* gfx2hlsl: lower the compute buffer store `off` form when its data is proven wave-uniform (R0Y00#2651)

* gfx2hlsl: lower the compute buffer store `off` form when its data is proven wave-uniform

A MUBUF store with neither offen nor idxen gives every lane the same byte
address (soffset plus the immediate), so the active lanes race on one
location. When every data VGPR holds one proven value in all enabled lanes
the order does not matter, and the store lowers like the offen form with no
VGPR term. The proof is the one v_readfirstlane_b32 already uses (entry
block with a known EXEC, or a recomputable expression with no join or EXEC
write since the definition), now shared as Stage.proven_uniform_v.

v_lshrrev_b64 / v_lshlrev_b64 / v_ashrrev_i64 with scalar or literal
sources now mark both destination halves uniform, under the same conditions
Stage.one applies to the 32-bit VALU forms.

Any other `off` store keeps a named refusal: "buffer store off with data not
proven wave-uniform". The atomic `off` form is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* tests: cover the off store proof past the entry block

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* tests: dispatch two off-store compute cases and decode the hand-assembled words

Cases O-dword (8 lanes, SGPR soffset plus immediate) and O-shift (32 lanes,
dwordx4 of a 64-bit shift of a scalar pair) store in the off form, so every
lane of a group writes one address. Their expected words are computed from
the instruction semantics, and the dispatch mode compares all 320 words.
The hand-assembled words are decoded with the repository disassembler and
must match their source lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: tedin7 <110300616+tedin7@users.noreply.github.com>

* shader: lower 64-bit scalar bit-count and scan ops in gfx2hlsl (Part of R0Y00#1723) (R0Y00#2072)

* shader: lower s_bcnt0/1, s_ff0/ff1_i32_b64 and s_flbit_i32_b64/i64 in gfx2hlsl (Part of R0Y00#1723)

* docs: document startup scalar bit count and scan lowering (Part of R0Y00#1723)

* test: draw the 64-bit scalar bit scans on the adapter and read them back (R0Y00#1723)

* docs: describe the scalar bit scan draw test and list it in the Linux checks (R0Y00#1723)

* Carry bit-scan words through the float render target

---------

Co-authored-by: Royoo <3230853833@qq.com>

* tests: batch heap-view store references by compute shader (R0Y00#2654)

Co-authored-by: RavenCurseBurg <360931527+RavenCurseBurg@users.noreply.github.com>
Co-authored-by: tedin7 <110300616+tedin7@users.noreply.github.com>

* runtime: create committed resources through device slot 76 (R0Y00#2648)

* runtime: create committed resources through device slot 76

Device slot 76 (Xbox order, +0x260) takes the seven arguments of desktop
CreateCommittedResource (heap properties, heap flags, desc, initial
state, clear value, riid, ppv); on main the wrapper trapped on it. A
console package module creates its resources through it.

The slot-127 body becomes create_committed(slot, ...): slot 127 calls it
as before, slot 76 without a protected session or castable formats, so
both share the per-heap initial state, clear-value retry and title
memory. The log line names the slot.

New fixture with a negative control: startup_committed_slot76_warp and
_hardware (a render target with a clear value and default, upload and
readback buffers); the control asks for a 2D texture on an upload heap.

* Require exact rejection in the slot 76 control

---------

Co-authored-by: Royoo <3230853833@qq.com>

* startup: lower abs (|src| and -|src|) on v_cndmask_b32_e64 sources (R0Y00#2439)

Co-authored-by: Royoo <3230853833@qq.com>

* startup: handle vertex fetch with invalid input layout in gfx2hlsl (Part of R0Y00#1723) (R0Y00#2002)

* startup: translate a stream vertex fetch whose pipeline declares an empty input layout

A stream vertex shader that calls the fetch routine was refused whenever the
pipeline had no input layout elements. A layout declared with zero elements is
now published as 'ia1 0'; the translator reads each fetched register as zero
instead of refusing. A stream without a readable layout is still refused.

* docs: describe the empty input layout request (ia1 0) and its zero default

* test: draw readback for an empty declared input layout

* fix: gate zero-element input layout zero-fill behind X2W_STREAM_ZERO_FILL opt-in

* shader: lower gfx1030 comparison sample LOD and bias (R0Y00#1568)

* compute: accept gfx1013 image_atomic_umin on R32_UINT

gfx1013 image atomics covered add, umax and cmpswap only; M200-01 A stops at
unsigned image minimum. Allow umin with the shared gfx1030 InterlockedMin
lowering, keep it unsigned, and extend the gfx1013 fixture (high-bit operand
0x80000011 vs smin). Other ops stay refused.

Refs R0Y00#2618

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>

* gfx2hlsl: lower the carry of adjacent compute address adds (R0Y00#2658)

Co-authored-by: RavenCurseBurg <360931527+RavenCurseBurg@users.noreply.github.com>

* shader: lower experimental gfx1030 2D sample clamps (R0Y00#1638)

Co-authored-by: tedin7 <110300616+tedin7@users.noreply.github.com>

* startup: return E_OUTOFMEMORY when a D3D12 wrapper cannot be allocated (R0Y00#2656)

* startup: return E_OUTOFMEMORY when a D3D12 wrapper cannot be allocated

wrap() used the _aligned_malloc result without a check, so a failed
allocation under the job commit limit became a write through a null
pointer inside d3d12_xs.dll (seen at the slot 55 derived-pipeline
placeholder). wrap() now returns nullptr when the allocation or the
registry insert fails. Each of its 16 callers releases the desktop
object it created and returns E_OUTOFMEMORY with a null output.

startup_wrap_allocation_warp forces the failure through the
fixture-only export x2w_d3d12_fail_wraps for device creation and slots
8, 14, 16 and 55; the control never arms it and must report the
failure.

Fixes R0Y00#2653

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* tests: cover the allocator, command list and committed-resource wrap failures

Review follow-up on R0Y00#2653. startup_wrap_allocation now also arms the
failure for device slot 9 (CreateCommandAllocator, the shared
create_slot path), slot 73 (command list) and slot 127 (committed
resource). Each must return E_OUTOFMEMORY with a null output, then
succeed. Removing the slot 73 null check makes the test crash at that
slot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Preserve the published D3D12 device on wrapper allocation failure

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Royoo <3230853833@qq.com>

* startup: lower one slot 57 scalar load in a pre-exchange execz block (R0Y00#2660)

A pre-exchange s_cbranch_execz block may hold one s_buffer_load_dword
whose result is live after the join, when EXEC there comes from
s_mov_b64 exec, -1 then v_cmpx_gt_u32_e32 of a wave-uniform SGPR bound
against the proven thread index, with no EXEC write or branch target in
between. The guest runs the block for the whole wave when any lane is
active, so the HLSL computes wave_any = (tid & ~63u) < bound at the
compare, branches around the block only when the wave is empty, and
gives the loaded word to every lane of a wave that has an active lane.
An empty wave issues no load and keeps the previous value. Vector writes
in the block stay predicated per lane. Other compares, non-uniform bounds
or offsets, s_load_dword, wider loads and a second live scalar stay
refused.

AI-assisted.

---------

Co-authored-by: Ammar Abdelfattah <a.mmar067a.mmar067@gmail.com>
Co-authored-by: tedin7 <110300616+tedin7@users.noreply.github.com>
Co-authored-by: JVProg <100954822+JVProg@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: dnn <55638248+denn0x@users.noreply.github.com>
Co-authored-by: Royoo <3230853833@qq.com>
Co-authored-by: Leyukaka <45659323+Leyukaka@users.noreply.github.com>
Co-authored-by: RavenCurseBurg <lycqay@gmail.com>
Co-authored-by: RavenCurseBurg <360931527+RavenCurseBurg@users.noreply.github.com>
Co-authored-by: Chad Hyatt <chad@hyatt.page>
Co-authored-by: lukaslw-lab <lukaslw@gmail.com>
Co-authored-by: lukaslw-lab <291379150+lukaslw-lab@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
Co-authored-by: chasegrindy <szymonkubica.biz@gmail.com>
Co-authored-by: chasegrindy <302242206+chasegrindy@users.noreply.github.com>
Co-authored-by: The Void <mrdominogrm@gmail.com>
Co-authored-by: tedin7 <tommasoderosa94@gmail.com>
Co-authored-by: NiiRoZz <simonin.remi25@gmail.com>
Co-authored-by: pigalot <pigalot@gmail.com>
Co-authored-by: triggered02 <153171514+triggered02@users.noreply.github.com>
Co-authored-by: yjs <1245206726@qq.com>
Co-authored-by: saii <120340942+Not-Saii@users.noreply.github.com>
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.

4 participants