shader: follow constant s_bfm and s_bitreplicate EXEC writes in whole-wave sections (#361) #362
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/362"
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 LakshanSivakumar/Native-Victory-macOS. Originally posted by tiagonogueiraa-bit on 2026-11-27T14:09:49Z.
Refs #361
Shape. The title's prefix sums run in whole-wave sections and select rows with constant EXEC writes:
row_shr1, 2, 4, 8), thens_bfm_b32 exec_lo, 16, 16andv_permlanex16_b32add lane 15 into the upper row;s_bitreplicate_b64_b32 exec, 0xff00ff00(the upper row of each half) withv_permlanex16_b32, thens_bfm_b64 exec, 32, 32adds lane 31 into the upper half.The simulator followed only
s_movEXEC writes, andwave::register_onlytook neither instruction. SoLower::section_inststopped at the opcode ("s_bfm_b32 is not supported"), or the section's values were left unknown and a later read was refused instead.Change.
wave::exec_constantgives the lane set of a constants_mov, of ans_bfm_b32ors_bfm_b64of two constant counts (((1 << S0) - 1) << S1, counts of 5 or 6 bits; SOP2 opcodes 36 and 37), or of ans_bitreplicate_b64_b32of a constant (bitito bits2iand2i + 1; SOP1 opcode 59).simulateuses it for EXEC writes, andregister_onlytakes those instructions when they write EXEC with constant operands.By-output corpus sweep. 12,020 containers from my own boot-to-menus run (Series S), native host options, main
905e7aaagainst this head:s_bfm_b32(9):1ba04ed0bdb9d8f7,34046961ba5a083e,6eb2cad0734f0844,71ffd0d7b57f5413,8c9f69d0d905ffe3,b8c3843f71fb4eaa,c38c7bd6ba697164,cbd298c95c519202,d9be592e55ce3180.s_bitreplicate_b64_b32(2):2f27e7c39c63e598,57112cf780dbfc5c.13e7b57cfa9850df,383a3512203c500b,816f5a360245eb94,9628f6ff142e1799,a733768e1c646908,fb2cbdf4ee7d984e. Each has the wave64 section above. Its values were unknown, so the refusal surfaced later, at a lane index read from the section's result (v_readlane_b32 sN, vM, sNbefore an atomic).6c7f547fee86539dgoes froms_bfm_b32to "a lane-mask join of an untracked mask: data, at a join of several edges", its next refusal.Tests. The GPU and lowering tests fail on main and pass here.
emit::wave::tests::s_bfm_gives_exec_its_field_of_constant_counts:s_bfminline and literal counts, the 5-bit wrap, the 64-bit form,s_bitreplicateof0xff00ff00and of an inline constant, and SGPR operands givingNone.emit::lower::tests::a_wave32_prefix_sum_may_set_its_upper_row_with_s_bfm: onedx.op.wavePrefixOp.i32.split_wave_tests::a_wave32_prefix_sum_whose_upper_row_s_bfm_selects_runs(victory-gpu, on Metal): laneistoressum(1..=i+1), also with lanes 20 and up off before the section.split_wave_tests::a_wave64_prefix_sum_whose_rows_s_bitreplicate_and_s_bfm_select_runs(victory-gpu, on Metal): 64 lanes across the two host waves of a console wave, laneistoressum(1..=i+1).Checks.
cargo test -p victory-shader -p victory-hle -p victory -p victory-gpu -p victory-metal -p xtask: 958 passed, 0 failed, 10 ignored.-D warnings: clean.cargo xtask policy: ok.docs/native-host.md("Whole-wave sections the simulation does not follow") describes the change. I haven't checked it in a game run. @Olima34, for the board.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T16:05:09Z.
Merged in
be7dc1b5with the other shader PRs from tonight. Ran the tests (native arm64), Windows clippy, the policy check and a release build on the merged tree, and swept my full corpus of 21,600 shaders before and after: 0 lost, 352 newly translated, every changed output accounted for. I have not run the game on it yet. Thanks.