feat(shader): implement the VOPC f64 compares #365
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/365"
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 DotDebian on 2026-10-02T15:17:18Z.
What
The 34 f64 compares threw "VOPC opcode is not implemented" (same in their VOP3 encodings):
v_cmp_{f,lt,eq,le,gt,lg,ge,o,u,nge,nlg,ngt,nle,neq,nlt,tru}_f64, the 16v_cmpx_*_f64,v_cmp_class_f64andv_cmpx_class_f64(opcodes 0x20-0x2f, 0x30-0x3f, 0xa8, 0xb8).emitFloat64Compareworks on the 64-bit pattern with the existing 64-bit integer IR: NaN ismagnitude > 0x7ff0000000000000, and the order comes from a signed key (the magnitude, negated when the sign bit is set, so -0 and +0 share key 0) compared withSLessThan64/IEqual64. Each predicate is a combination of less / equal / greater / unordered. The result is exact for every input, denormals included, and needs noshaderFloat64.emitFloat64ClassComparepicks the class bit (sNaN, qNaN, -inf, -normal, -denormal, -0, +0, +denormal, +normal, +inf) from the exponent and fraction fields and tests it in the mask, like the f32 class compare.readF64Bitsreads an f64 source: register pair,abs/negon bit 63, a 32-bit literal as the high half (the rule for f64 operands;readU32Pairzero-extends, which is the integer rule), and inline constant 248 as the double 1/(2*pi) (0x3fc45f306dc9c882) rather than the widened float.Notes:
negon a VOP3-encoded compare is still rejected bycheckNativeVop3Modifiers(#260 changes that).readF64Bitsalready applies it, so nothing more is needed here once #260 is merged, but that path is not reachable by a test until then.Tested
Windows 11, MinGW-w64 GCC 15.2.0, NVIDIA RTX 5080.
New test
agc_driver_vopc_compare_f64, built likeagc_driver_vopc_compare: a wave32 compute shader runs 41 compares and packs one bit per lane (v_cndmaskof VCC, orv_movunder the EXEC acmpxleaves). It covers the 34 opcodes in the VOPC encoding, a 32-bit literal source, the inline constants 1.0, 1/(2*pi) and integer 1, and three VOP3 encodings withabs(v_cmp_lt,v_cmp_class,v_cmpx_ngt). 17 dispatches: every ordered pair of 20 edge values (quiet and signalling NaN, NaN whose fraction is only in the low or only in the high word, +-inf, +-0, denormals, values that differ in the low word only) with 16 class masks, then pseudo-random patterns. A C++ model on hostdoublechecks every bit.mainwith "VOPC opcode is not implemented", passes with the change.abs, sign in the order key, NaN bounds, class fields, swapped predicates, swapped encodings) each make it fail.ctest: 109/109.The shader words are assembled by hand (no
llvm-mchere); the encodings were checked against LLVM'sVOPCInstructions.td(GFX10 column).Not tested: Linux (lavapipe, RADV),
neg(see above), any title.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-02T15:17:45Z.
Progress report (
313de1c→bd75a89)📈 GPU shader instructions: 62.52% (+2.91%, +34 implemented instructions)
✅ 34 implemented
V_CMPX_CLASS_F64V_CMPX_EQ_F64V_CMPX_F_F64V_CMPX_GE_F64V_CMPX_GT_F64V_CMPX_LE_F64V_CMPX_LG_F64V_CMPX_LT_F64V_CMPX_NEQ_F64V_CMPX_NGE_F64V_CMPX_NGT_F64V_CMPX_NLE_F64V_CMPX_NLG_F64V_CMPX_NLT_F64V_CMPX_O_F64V_CMPX_TRU_F64V_CMPX_U_F64V_CMP_CLASS_F64V_CMP_EQ_F64V_CMP_F_F64V_CMP_GE_F64V_CMP_GT_F64V_CMP_LE_F64V_CMP_LG_F64V_CMP_LT_F64V_CMP_NEQ_F64V_CMP_NGE_F64V_CMP_NGT_F64V_CMP_NLE_F64V_CMP_NLG_F64V_CMP_NLT_F64V_CMP_O_F64V_CMP_TRU_F64V_CMP_U_F64Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-03T07:58:47Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/shader/recompiler/Translation/include/Translation/TranslationContext.hppL53