startup: lower v_mad_u32_u16 in gfx2hlsl #2425
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2433"
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 triggered02 on 2026-11-25T16:35:20Z.
Lowers unmodified gfx1013 VOP3A
v_mad_u32_u16(0x373) intools/startup/gfx2hlsl.py.### Semantics & scope- RDNA 2 ISAv_mad_u32_u16 vD, S0, S1, S2(when unmodified:op_sel:[0,0,0], noclamp/omod/abs/neg):D.u32 = (S0.u32 & 0xffffu) * (S1.u32 & 0xffffu) + S2.u32(unsigned 32-bit wraparound).- Added'v_mad_u32_u16': (3, '({0} & 0xffffu) * ({1} & 0xffffu) + {2}')toVEC_Uintools/startup/gfx2hlsl.py.-Stage.lowerreadsS0andS1withlow16_only=True(since only bits[15:0]are read) andS2withlow16_only=False(all 32 bits read), clearinglow16_only_von the 32-bit destination.- Modifiers (op_sel,clamp,omod,abs,neg) and wrong operand counts remain refused.### Measured checks (3dd333fconorigin/main; the head is tedin7's merge of main into this branch, rebuilt and re-tested)-tests/startup_gfx2hlsl_mad_u32_u16_check.py(pure Python): PASS � synthetic VOP3A bytes decoded withgfx2hlsl.decode, 1,800 32-bit input triples (including upper-16 garbage bits onS0/S1,0xffff * 0xffff, 32-bit wraparound withS2 = 0xffffffff, andS2upper-bit preservation) evaluated against((s0 & 0xffff) * (s1 & 0xffff) + s2) & 0xffffffff,low16_onlychecks, 8 modifier refusals, 2 arity refusals, unlowered control, and 3 HLSL mutations.-tests/startup_gfx2hlsl_mad_u32_u16_check.py draw <dxc> <offscreen_check> warp <fxc>: PASS on Microsoft Basic Render Driver (1414:008c,10.0.26100.9818) for both FXC (ps_5_1) and DXC (ps_6_0), 3 four-lane chunks plus all 3 mutated draws (drop_s0_mask,drop_s1_mask,mask_s2) mismatching as expected.- 63/63 pure-Pythonstartup_gfx2hlsl_*_check.py+startup_translator_check.py,docs_links_check.py(468 links),bidi_controls_check.py(1,726 files),git diff --check: all PASS.- 4 fail-first mutations ontools/startup/gfx2hlsl.py(droppingS0/S1& 0xffffu, maskingS2, removingv_mad_u32_u16): all 4 caught (exit 1).### Not established- AMD hardware was not exercised. The physical-GPUhardwaredraw has since been measured by @Makto94 on an NVIDIA GeForce RTX 3070 Ti (driver 32.0.16.2101), Windows 11 build 26300.9974, MSVC 19.44.35230,devpreset, serial-j1runs:startup_gfx2hlsl_mad_u32_u16_hardwarepassed withdebug_errors=0 debug_warnings=0, 0 capability skips, and thedrop_s0_mask,drop_s1_maskandmask_s2mutations each reportedfails as expectedin both the FXC and DXC paths (report: https://github.com/R0Y00/Xbox2Windows/pull/2433#issuecomment-7170699389). Thebinary <llvm-mc>mode was still not run locally.AI-assisted (Gemini).- Win2025 WARP receipt (tedin7, head3dd333fc): dev and /O2 release builds, startup_gfx2hlsl_mad_u32_u16_controls + _warp 2/2 passed in both presets, plus the full Windows pure-Python check list (66 checks, all ok except the POSIX-only startup_run_sh_check.py skip). Report: https://github.com/R0Y00/Xbox2Windows/pull/2433#issuecomment-7173370606Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T16:35:30Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
f6d1f4bℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T18:24:21Z.
Review: COMMENTED
Review of head
f6d1f4bb(comment only, no merge action).What I checked
VEC_Uentry({0} & 0xffffu) * ({1} & 0xffffu) + {2}matches the unsigned low-16 multiply with a 32-bit addend and wraparound. The special case inStage.lowerreads S0 and S1 withlow16_only=Trueand S2 as a full 32-bit value, which is right. The change is small and additive.v_mad_u32_u24entry and the 16-bit ternary ops (#834) were inspected. This op is not covered there and no other open or merged PR lowersv_mad_u32_u16. #532 is a draft for integer multiplies and does not touch it.0xffff * 0xffffand S2 wraparound. It refuses modifiers and bad operand counts. It has a real WARP draw readback (FXC and DXC) with mutated-shader controls, and CTest entries for warp and hardware.f6d1f4bb, the same SHA I reviewed. I did not run Windows tests myself. The author notes that hardware andbinary <llvm-mc>modes were not run.Commands run locally (Linux)
python3 -B tests/startup_gfx2hlsl_mad_u32_u16_check.py: passpython3 -B tests/startup_gfx2hlsl_mad_check.py: passpython3 tests/docs_links_check.py: passpython3 tests/bidi_controls_check.py: passgit diff --check origin/main...HEAD: clean& 0xffffuon S0 in theVEC_Uentry. The test fails (exit 1).low16_only=True. The test fails (exit 1).No blocking findings.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by Makto94 on 2026-11-25T18:17:10Z.
Hardware run and Windows 11 MSVC build at head
f6d1f4bb.Environment: Windows 11 Pro build 26300.9974, Debug (
devpreset), MSVC toolset 14.44.35207 (cl 19.44.35230.0), driver 32.0.16.2101. The hardware test printsadapter=NVIDIA GeForce RTX 3070 Ti vendor=10de device=2482andbackend=hardware debug_layer=enabled, withdebug_errors=0 debug_warnings=0. The runs were serial (-j1).Build:
cmake --build --preset devexited 0. This PR changes no C++ source.Tests:
ctest --preset dev --no-tests=error -j1 -R 'startup_gfx2hlsl_mad_u32_u16' -E 'hardware' -V: 2/2 passed (startup_gfx2hlsl_mad_u32_u16_controls,_warp).ctest --preset dev --no-tests=error -j1 -R 'startup_gfx2hlsl_mad_u32_u16_hardware' -V: 1/1 passed. 0 capability skips (77).The hardware test reads back draw chunks 0 to 2 through both the fxc and the dxc path. The mutations
drop_s0_mask,drop_s1_maskandmask_s2each printfails as expectedin both paths, so the check can fail. The log shows no final summary line from this test; the pass rests on the ctest result.The PR body lists as not established: "Physical GPU
hardwaredraw was not run locally (WARP only)." This run adds that measurement.Not covered by this run: AMD hardware; only these three chunks were run.
Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-25T18:45:44Z.
Thanks � recorded in the PR description. The physical-GPU hardware draw is no longer listed as not established: the body now cites your RTX 3070 Ti run (driver 32.0.16.2101, Windows build 26300.9974, MSVC 19.44.35230, dev preset, debug_errors=0 debug_warnings=0, 0 skips), the three chunks read back through both the FXC and DXC paths, and that drop_s0_mask, drop_s1_mask and mask_s2 each reported \ails as expected, with a link to your comment. I kept two honest limits in the body: the inary mode still has not been run locally, and AMD hardware is unexercised. Head is unchanged at 6d1f4bb, so your measurement is of the current head.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T20:02:14Z.
Review: COMMENTED
Review of head
214277ac(comment only, no approval).Checked:
D = (S0 & 0xffff) * (S1 & 0xffff) + S2with 32-bit wrap, S2 read in full. Matches the VOP3A form; modifiers and wrong arity stay refused.low16_onlyon S0/S1 only, S2 full width: correct, no sibling table needs the same entry (checkedVEC_Unext tov_mad_u32_u24).v_mad_u32_u16(searched all states).v_mad_*tests.Commands run locally on this head:
python3 tests/startup_gfx2hlsl_mad_u32_u16_check.pyPASSpython3 tests/docs_links_check.pyPASS (481 links)python3 tests/bidi_controls_check.pyPASSgit diff --check origin/main...HEADcleanS1 & 0xffffumask inVEC_Umade the check exit 1 (reverted).Not claimed: no executable or game result. This is a fixture-level lowering only.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T20:14:00Z.
Win2025 WARP receipt for head
3dd333fcafter updating with main.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
3dd333fc5d36c0258902e25014e62004e882a5b4:--preset dev):cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim -- -j 2):52.09s(configure3.90s)ctest --preset dev -R 'startup_gfx2hlsl_mad_u32_u16_(controls|warp)' --parallel 2 --no-tests=error --output-on-failure): 2/2 passed (6.54s:startup_gfx2hlsl_mad_u32_u16_controls0.90s,startup_gfx2hlsl_mad_u32_u16_warp4.53s)/O2(--preset release):cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim -- -j 2):79.83s(configure14.22s)ctest --preset release -R 'startup_gfx2hlsl_mad_u32_u16_(controls|warp)' --parallel 2 --no-tests=error --output-on-failure): 2/2 passed (1.85s:startup_gfx2hlsl_mad_u32_u16_controls0.24s,startup_gfx2hlsl_mad_u32_u16_warp1.65s)tests/mesh_heap_sampler_check.pyok (1.4s),tests/startup_buffer_address_check.pyok (1.0s),tests/startup_compute_request_offline_check.pyok (0.9s),tests/startup_compute_translate_check.pyok (0.5s),tests/startup_flat_param_check.pyok (0.2s),tests/startup_gfx2hlsl_add_sub_co_check.pyok (0.2s),tests/startup_gfx2hlsl_add_sub_co_ci_check.pyok (0.3s),tests/startup_gfx2hlsl_bit_alu_check.pyok (1.4s),tests/startup_gfx2hlsl_capture_check.pyok (1.8s),tests/startup_gfx2hlsl_cmp16_check.pyok (0.4s),tests/startup_gfx2hlsl_compare_dst_check.pyok (0.2s),tests/startup_gfx2hlsl_compute_check.pyok (0.7s),tests/startup_gfx2hlsl_cselect_mask_check.pyok (0.2s),tests/startup_gfx2hlsl_cvt_alu_check.pyok (0.2s),tests/startup_gfx2hlsl_f32_lg_check.pyok (2.4s),tests/startup_gfx2hlsl_f32_nan_check.pyok (9.7s),tests/startup_gfx2hlsl_getpc_refusal_check.pyok (0.2s),tests/startup_gfx2hlsl_handler_arity_check.pyok (0.2s),tests/startup_gfx2hlsl_image_arity_check.pyok (0.2s),tests/startup_gfx2hlsl_image_get_lod_check.pyok (0.2s),tests/startup_gfx2hlsl_int_med3_check.pyok (0.2s),tests/startup_gfx2hlsl_join_symbols_check.pyok (0.4s),tests/startup_gfx2hlsl_loop_constants_check.pyok (0.2s),tests/startup_gfx2hlsl_mask_overwrite_check.pyok (0.2s),tests/startup_gfx2hlsl_operand_count_check.pyok (0.5s),tests/startup_gfx2hlsl_pack_absdiff_check.pyok (5.0s),tests/startup_gfx2hlsl_readfirstlane_recompute_check.pyok (0.2s),tests/startup_gfx2hlsl_readfirstlane_uniform_check.pyok (0.2s),tests/startup_gfx2hlsl_refusals_check.pyok (0.8s),tests/startup_gfx2hlsl_root_check.pyok (1.5s),tests/startup_gfx2hlsl_sad_check.pyok (0.6s),tests/startup_gfx2hlsl_saveexec_same_reg_check.pyok (0.2s),tests/startup_gfx2hlsl_scalar_arity_check.pyok (0.4s),tests/startup_gfx2hlsl_scalar_brev_fold_check.pyok (0.3s),tests/startup_gfx2hlsl_scalar_m0_check.pyok (0.2s),tests/startup_gfx2hlsl_scalar_table_arity_check.pyok (0.6s),tests/startup_gfx2hlsl_sdwa_cvt_check.pyok (0.6s),tests/startup_gfx2hlsl_sgpr_spill_check.pyok (0.2s),tests/startup_gfx2hlsl_shift64_check.pyok (0.3s),tests/startup_gfx2hlsl_smem_offset_check.pyok (0.2s),tests/startup_gfx2hlsl_sop2_complement_check.pyok (14.0s),tests/startup_gfx2hlsl_sopk_accum_check.pyok (1.7s),tests/startup_gfx2hlsl_sopk_signext_check.pyok (0.2s),tests/startup_gfx2hlsl_swap_check.pyok (0.5s),tests/startup_gfx2hlsl_vopc_sdwa_check.pyok (8.9s),tests/startup_gfx2hlsl_waitcnt_depctr_check.pyok (0.2s),tests/startup_gfx2hlsl_watch_check.pyok (3.2s),tests/startup_image_2d_array_check.pyok (0.3s),tests/startup_image_3d_check.pyok (0.2s),tests/startup_image_gather_lz_check.pyok (1.0s),tests/startup_image_load_d16_check.pyok (1.8s),tests/startup_image_sample_a16_check.pyok (0.3s),tests/startup_image_sample_b_check.pyok (0.3s),tests/startup_image_sample_c_check.pyok (0.3s),tests/startup_image_sample_l_check.pyok (0.3s),tests/startup_image_sample_lod_check.pyok (1.2s),tests/startup_inline_sampler_check.pyok (0.3s),tests/startup_mesh57_skeleton_check.pyok (0.3s),tests/startup_run_ps1_check.pyok (16.8s),tests/startup_run_sh_check.pyskipped (0.1s),tests/startup_sampler_heap_check.pyok (0.2s),tests/startup_shader_cache_rekey_check.pyok (3.1s),tests/startup_smem_address_check.pyok (0.2s),tests/startup_stream_fetch_check.pyok (0.3s),tests/startup_stream_interface_check.pyok (0.4s),tests/startup_translator_check.pyok (0.7s)sccache: 7/221 hits; wall255.7sAI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-25T20:19:55Z.
Thanks for the Win2025 receipt � recorded it in the description against head
3dd333fc(your merge of main), with the dev and /O2 builds, the 2/2 startup_gfx2hlsl_mad_u32_u16_{controls,warp} runs in both presets, and the full Windows pure-Python list (everything ok except the POSIX-only startup_run_sh_check.py skip). Link: https://github.com/R0Y00/Xbox2Windows/pull/2433#issuecomment-7173370606Nothing else changed on this branch: head is still your
3dd333fc, and I have not pushed over it. The only open item in the description is AMD hardware, which stays listed as unexercised.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T02:12:15Z.
Review: COMMENTED
Review of head
17db2d66(merge of main into the PR branch; the PR's own change is unchanged since the earlier reviewed head).Checked:
CMakeLists.txt(test registration block) anddocs/experiments.md(section order). Both sides are kept; themad_u32_u16controls, warp and hardware tests are still registered and still run.git diff 3dd333fc..HEAD -- tools/startup/gfx2hlsl.pyis only main's changes; thev_mad_u32_u16lowering and its CPU-reference WARP draw test are untouched.python3 -B tests/startup_gfx2hlsl_mad_u32_u16_check.py(includes the mutation controls and the unlowered-refusal control),python3 tests/docs_links_check.py,python3 tests/bidi_controls_check.py,git diff --check origin/main...HEAD: all clean.No blocking findings.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T02:11:26Z.
Pushed a merge of
origin/maininto this branch (merge commit, no rebase, no force) to resolve the conflicts inCMakeLists.txtanddocs/experiments.md. Both sides were kept; nothing else changed.Verification:
python3 -B tests/startup_gfx2hlsl_mad_u32_u16_check.py: self-test passed.python3 tests/docs_links_check.py,python3 tests/bidi_controls_check.py,git diff --check origin/main...HEAD: clean.3dd333fc:ctest --preset dev -R 'mad_u32_u16' --no-tests=error: 3/3 passed (controls, warp, hardware).ctest --preset release -R 'mad_u32_u16' --no-tests=error: 3/3 passed.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T02:12:03Z.
Win2025 WARP receipt for head
17db2d66after updating with main (run on the PR head plus the main-merge patch, i.e. the identical tree).Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
17db2d6688b77a2bb13fbe80f9eb66c8be77f806(17db2d66):--preset dev):cmake --build --preset dev --target offscreen_check -- -j 2):203.75s(configure4.13s)ctest --preset dev -R 'mad_u32_u16' --parallel 2 --no-tests=error --output-on-failure): 3/3 passed (3.15s:startup_gfx2hlsl_mad_u32_u16_controls0.39s,startup_gfx2hlsl_mad_u32_u16_warp2.57s,startup_gfx2hlsl_mad_u32_u16_hardware2.51s)/O2(--preset release):cmake --build --preset release --target offscreen_check -- -j 2):261.71s(configure5.11s)ctest --preset release -R 'mad_u32_u16' --parallel 2 --no-tests=error --output-on-failure): 3/3 passed (2.22s:startup_gfx2hlsl_mad_u32_u16_controls0.33s,startup_gfx2hlsl_mad_u32_u16_warp1.89s,startup_gfx2hlsl_mad_u32_u16_hardware1.68s)tests/mesh_heap_sampler_check.pyok (1.2s),tests/startup_buffer_address_check.pyok (0.8s),tests/startup_compute_request_offline_check.pyok (0.7s),tests/startup_compute_translate_check.pyok (0.3s),tests/startup_flat_param_check.pyok (0.3s),tests/startup_gfx2hlsl_add_sub_co_check.pyok (0.2s),tests/startup_gfx2hlsl_add_sub_co_ci_check.pyok (0.2s),tests/startup_gfx2hlsl_bit_alu_check.pyok (1.1s),tests/startup_gfx2hlsl_capture_check.pyok (1.6s),tests/startup_gfx2hlsl_cmp16_check.pyok (0.5s),tests/startup_gfx2hlsl_compare_dst_check.pyok (0.1s),tests/startup_gfx2hlsl_compute_check.pyok (0.7s),tests/startup_gfx2hlsl_cselect_mask_check.pyok (0.2s),tests/startup_gfx2hlsl_cvt_alu_check.pyok (0.3s),tests/startup_gfx2hlsl_f32_lg_check.pyok (1.5s),tests/startup_gfx2hlsl_f32_nan_check.pyok (7.7s),tests/startup_gfx2hlsl_getpc_refusal_check.pyok (0.2s),tests/startup_gfx2hlsl_handler_arity_check.pyok (0.2s),tests/startup_gfx2hlsl_image_arity_check.pyok (0.2s),tests/startup_gfx2hlsl_image_get_lod_check.pyok (0.3s),tests/startup_gfx2hlsl_int_med3_check.pyok (0.2s),tests/startup_gfx2hlsl_join_symbols_check.pyok (0.4s),tests/startup_gfx2hlsl_loop_constants_check.pyok (0.2s),tests/startup_gfx2hlsl_mask_overwrite_check.pyok (0.2s),tests/startup_gfx2hlsl_operand_count_check.pyok (0.6s),tests/startup_gfx2hlsl_pack_absdiff_check.pyok (3.9s),tests/startup_gfx2hlsl_readfirstlane_recompute_check.pyok (0.2s),tests/startup_gfx2hlsl_readfirstlane_uniform_check.pyok (0.2s),tests/startup_gfx2hlsl_refusals_check.pyok (0.9s),tests/startup_gfx2hlsl_root_check.pyok (1.3s),tests/startup_gfx2hlsl_sad_check.pyok (0.6s),tests/startup_gfx2hlsl_saveexec_same_reg_check.pyok (0.2s),tests/startup_gfx2hlsl_scalar_arity_check.pyok (0.4s),tests/startup_gfx2hlsl_scalar_brev_fold_check.pyok (0.3s),tests/startup_gfx2hlsl_scalar_m0_check.pyok (0.3s),tests/startup_gfx2hlsl_scalar_table_arity_check.pyok (0.6s),tests/startup_gfx2hlsl_sdwa_cvt_check.pyok (0.5s),tests/startup_gfx2hlsl_sgpr_spill_check.pyok (0.3s),tests/startup_gfx2hlsl_shift64_check.pyok (0.4s),tests/startup_gfx2hlsl_smem_offset_check.pyok (0.2s),tests/startup_gfx2hlsl_sop2_complement_check.pyok (11.1s),tests/startup_gfx2hlsl_sopk_accum_check.pyok (1.5s),tests/startup_gfx2hlsl_sopk_signext_check.pyok (0.2s),tests/startup_gfx2hlsl_swap_check.pyok (0.6s),tests/startup_gfx2hlsl_vopc_sdwa_check.pyok (8.1s),tests/startup_gfx2hlsl_waitcnt_depctr_check.pyok (0.2s),tests/startup_gfx2hlsl_watch_check.pyok (3.1s),tests/startup_image_2d_array_check.pyok (0.3s),tests/startup_image_3d_check.pyok (0.3s),tests/startup_image_gather_lz_check.pyok (0.8s),tests/startup_image_load_d16_check.pyok (1.6s),tests/startup_image_sample_a16_check.pyok (0.4s),tests/startup_image_sample_b_check.pyok (0.4s),tests/startup_image_sample_c_check.pyok (0.4s),tests/startup_image_sample_l_check.pyok (0.3s),tests/startup_image_sample_lod_check.pyok (1.1s),tests/startup_inline_sampler_check.pyok (0.3s),tests/startup_mesh57_skeleton_check.pyok (1.6s),tests/startup_run_ps1_check.pyok (14.2s),tests/startup_run_sh_check.pyskipped (0.1s),tests/startup_sampler_heap_check.pyok (0.2s),tests/startup_shader_cache_rekey_check.pyok (3.2s),tests/startup_smem_address_check.pyok (0.2s),tests/startup_stream_fetch_check.pyok (1.6s),tests/startup_stream_interface_check.pyok (3.8s),tests/startup_translator_check.pyok (2.4s)sccache: 26/328 hits; wall581.9sAI-assisted; commands listed were executed locally.