Vertex fetch scanner ignores the S_BFE_U32 width when folding constants #2370
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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:34Z.
EmbeddedVertexFetchAnalyzerfoldsS_BFE_U32on two constant SGPRs assrc0 >> (src1 & 31)(theSBfeU32case inAnalyze,core/shader/recompiler/Translation/src/EmbeddedVertexFetch.cpp). It ignores the width in S1 bits [22:16]. The instruction usesoffset = S1 & 31andwidth = (S1 >> 16) & 0x7f. It returns 0 for width 0, and otherwiseS0 >> offsetmasked towidthbits, where a width of 32 or more keeps every bit. The translator'ssBfeU32/extractBits32inIntegerInstructions.cppalready does this, so the scanner and the translator disagree.Example: S0 = 0x9e000000, S1 = 0x001e0000 (offset 0, width 30). The instruction gives 0x1e000000 and the scanner gives 0x9e000000.
The folded value can end up as an SMEM offset into the buffer table, and then the plan picks the wrong vertex buffer slot for the embedded fetch. With that pair as the
s_load_dwordx4offset, the scanner reports slot 165675008 instead of 31457280.I found it with an SMT check of the scanner's constant folds against the instruction semantics.
AI-assisted: yes