fix(recompiler): apply the S_BFE_U32 width when the vertex fetch scanner folds constants #2371
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2371"
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 boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-09T16:40:36Z.
Closes #2370
What
The embedded vertex fetch scanner folded
S_BFE_U32on constant SGPRs as a plain right shift and ignored the width field. It now callsscalarBfeU32, which matches the translator'ssBfeU32: offsetS1 & 31, width(S1 >> 16) & 0x7fclamped to 32, and 0 when the width is 0.The other ops that reach that switch are
S_AND_B32,S_LSHL_B32,S_ADD_I32andS_ADD_U32(isAttributePropagationAlu). The two adds land in thedefaultcase, which adds, so those are correct.Tested
New test
agc_embedded_vertex_fetch. It decodes a vertex program that builds an SMEM offset withs_mov_b32ands_bfe_u32, loads a buffer descriptor from the buffer table at that offset, and fetches withbuffer_load_format_xyzwon the vertex index. It checks the buffer slot the plan records.maind70b8998ctest -R agc_ -j1on Linux (Nobara 44, GCC 16): 257 of 258 on an RTX 5070 Ti (NVIDIA 595.91.07) and 258 of 258 on RADV (Ryzen 5 7600X iGPU, Mesa 26.2.1). The NVIDIA failure,agc_driver_dcc_keys_first_write, fails the same way onmaind70b8998.tools/check_conventions.py: passes.Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-09T17:44:12Z.
Linux run: Linux 7.2 (x86_64), GCC 16.2.1, Release,
-DBUILD_TESTING=ON, #2371 (f00c2f2d) tested on currentmain(0fdda7be).tests/agc_embedded_vertex_fetch_tests: passes cleanly.tools/check_conventions.py: passes cleanly.Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T19:42:34Z.
Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head
f00c2f2d, merged ontomain8b393b6ein one build with 31 other PRs that had no Windows run.agc_embedded_vertex_fetch.guest_offline_imports, broken by #2359 (reported there).No title was run.
🤖 Addressed by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-10T01:27:03Z.
Hardware measurement of
s_bfe_u32, and a run of the PR. Radeon 610M (gfx1036),tools/hw-oracleatmain0c0dc1e9, Linux 7.2.9, hsa-rocr 7.2.4, clang 23.1.1; ieee 0, dx10_clamp 1, denorm32 0, denorm16 3, round32 0, round16 0, fp16_overflow 0.405 rows: sources 0x9e000000, 0xfff00320, 0x00000320, 0xffffffff, 0x80000001 × offsets 0, 4, 31 × widths 0, 1, 8, 30, 31, 32, 33, 64, 127, each with the remaining S1 bits clear, with bit 23 set, and with 0xff00ffe0 set. Every row equals this PR's
scalarBfeU32(compiled unchanged);main'ssrc0 >> (src1 & 31)differs on 123 of them. SCC isresult != 0in every row.PR head
f00c2f2dmerged ontomain0c0dc1e9, Linux, GCC 16.2.1, Release:agc_embedded_vertex_fetchpasses. WithEmbeddedVertexFetch.cppreverted tomainit fails with slots 165675008, 16773123 and 50, as in the PR's table.Not measured: gfx1013.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-10T01:41:54Z.
@fma-rc thanks for the hardware rows. The widths 33, 64 and 127 also settle the one thing I hadn't checked on hardware: a width of 32 or more keeps every bit above the offset, rather than wrapping modulo 32. That matches the translator's
extractBits32, which this PR copies.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T06:16:14Z.
Checked on a merged tree:
agc_embedded_vertex_fetchpasses and fails with the fix reverted; HW oracle (gfx1035, 405 rows over sources × offsets × widths 0..127 × high S1 bits) matchesscalarBfeU32on every row,maindiffers on 123. Consistent with the runs by @Kikoarl, @popcoder565 and @fma-rc. Merging.