Conversation
cmake: enable VU0/ASM options and wire test execution docs(vu0): add emulation caveats and tests README note (fobes.dev) docs(vu0): add copilot-instructions and consolidate VU0 sources tests: add VU mul emulator-detection helper and global flag tmp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrate
ps2stuffVU0 vector / matrix primitives from the legacy SCEAee-gccinline-asm form (which relied on a custom"j"constraint that nolonger exists in upstream GCC) to a portable inline-asm form that builds
cleanly with the current
mips64r5900el-ps2-elf-g++toolchain, and add acomprehensive unit-test harness that runs on hardware and PCSX2.
What's in here
Inline-asm migration (VU0 path)
include/ps2s/vector.h,vector_common.h,matrix.h,matrix_common.h,vu.h: rewrite all VU0 inline-asm blocks to standard GCC syntax(
"r"GPR constraints + explicitqmtc2/qmfc2/lqc2/sqc2/ctc2).matrix.h/matrix_common.h(mat_33/mat_43mult_tilde,get_row*, quaternionset, etc.) by replacing the obsolete"j"constraint with"r"+explicit transfers.
transform_toperators andmat_33::inverse/transform_t::inverseusedirect
lqc2/sqc2memory paths to bypass a GCC TI-mode split-registerbug that truncates the upper half of 128-bit values when routed through
GPRs.
CPU compatibility / fast-path additions
include/ps2s/cpu_compat_types.h: complete C++ fallback forvec_x/y/z/w/xy/xyz/xyzw,mat_33/34/43/44,transform_twith no VU0dependencies. Enables building / testing the higher-level API on plain
CPU MIPS code.
cpu_vec_4is nowalignas(16);+,-, unary-,*operators getVU0 macro-mode asm fast paths (gated on
!NO_VU0_VECTORS).cpu_mat_44 * cpu_vec_4andcpu_mat_44 * cpu_mat_44get VU0 macro-modeasm fast paths using
vmulax/vmadday/vmaddaz/vmaddw.Tests
tests/test_shared.cpp: 140 VU0-build tests covering vec_3 / vec_4,mat_33 / mat_34 / mat_43 / mat_44 arithmetic, transposes, rotations,
mult_tilde,inverse,transform_toperations, accumulator ops, andthe new
cpu_vec_4/cpu_mat_44VU0 fast paths.test_cpu_shared.elf)via
-DUSE_CPU_COMPAT, exercisingcpu_compat_types.hand the scalarpaths of
cpu_vector.h/cpu_matrix.h.1*X != Xmultiply quirk (see https://fobes.dev/ps2/detecting-emu-vu-floats).
tests/README.mddocuments how to build/run on hardware (ps2client)and in PCSX2.
Build
CMakeLists.txt/tests/CMakeLists.txt: addENABLE_VU0_VECTORSandENABLE_ASMoptions; wire up bothtest_vu0.elfandtest_cpu_shared.elftargets.CMAKE_BUILD.md: updated build instructions.Test results
Both test binaries verified in PCSX2:
test_vu0.elf: 140 / 140 passedtest_cpu_shared.elf: 147 / 147 passedNotes for reviewers
SCEA form because upstream GCC has no register class for VU0
$vfNNregisters and no
"j"constraint. Restoring a first-class VU0 backendin upstream GCC would let us shrink these blocks back to near-original
size; this is documented separately (not included in this PR) for a
future effort.
vsuba $ACC, $vf0, $vf0pattern is used instead ofvadda $ACC, $vf0, $vf0because the latter does not reliably sync theMAC pipeline in this codebase's contexts.