-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Soft-Float] - Initial Interpreter Implementation of Ps2's floating point unit specification #12001
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for submitting a contribution to PCSX2
As this is your first pull request, please be aware of the contributing guidelines.
Additionally, as per recent changes in GitHub Actions, your pull request will need to be approved by a maintainer before GitHub Actions can run against it. You can find more information about this change here.
Please be patient until this happens. In the meantime if you'd like to confirm the builds are passing, you have the option of opening a PR on your own fork, just make sure your fork's master branch is up to date!
Does this work on the recompilers or just interpreter? |
You should try reading the title. |
…oint unit specification. This Pull Request implements the first take ever on real Soft-Float support in PCSX2. This work is a combination or several efforts and researches done prior. Credits: - https://www.gregorygaines.com/blog/emulating-ps2-floating-point-nums-ieee-754-diffs-part-1/ - https://github.com/GitHubProUser67/MultiServer3/blob/main/BackendServices/CastleLibrary/EmotionEngine.Emulator/Ps2Float.cs - https://github.com/Goatman13/pcsx2/tree/accurate_int_add_sub - PCSX2 Team for their help and support in this massive journey. This pull request should be tested with every games requiring a clamping/rounding mode (cf: GameDatabase). Currently, this PR fixes on the interpreters: - PCSX2#354 - PCSX2#11507 - PCSX2#10519 - PCSX2#8068 - PCSX2#7642 - PCSX2#5257 This is important to note, that this implementation, while technically fixing Gran Turismo 4 and Klonoa 2, makes the games crash due to very high floats being passed in the emu code, and failing at some points later in the process. This has not yet been ironed-out. Other than that, this sets the floor for Soft-Float in PCSX2, a long awaited contribution.
96414bd
to
de047ea
Compare
I don’t know why my brain just skimmed over that. |
I ran a bunch of tests for "Test Drive Unlimited" AI during the demo scene after sitting idle on the menu. No combination of settings/interpreters seems to have any effect on behavior. There must be something else going on |
Shouldn't this help with #2990 as well? |
I remember seeing on the public dev channel that stuntman not longer had AI issues with this and not longer the car AI failed? it's been a while |
I tested the demo replays of Tokyo Xtreme Racer Zero (see issue #5597 ) and noticed that the car movement in interpreter mode is now closer to the movement in recompiler mode. comp.mp4 |
The game sends some super low floats to the Mul unit. On PS2, floats with exponent zero should return zero, but this is not the case in Mul, the multiplier can work with denormals internally. I love when undocumented stuff is used by some games for their 3D engine ^^.
The Tony Hawk case is fixed, the game uses an un-documented behaviour in it's 3D engine. The PS2 has no denormals support .... except in the Mul unit apparently. The behaviour is now emulated properly. |
@AmyRoxwell Can you provide a reference to this? There's no indication of it being fixed in #2990, and I assume the devs would have closed it if it were. In any event it involves pathing in Driver 3 as well. |
2024-11-10.14-28-32.mp4This also affects the Fatal Frame 1 issue. Meaning this + the current GameDB patch will end up being the ultimate fix |
More accurate approach to compare.
This pr's EE interpreter fixes #11636 's gamedb issue. |
Implements accurate SQRT options, also removes Tri-Ace hack, which isn't needed anymore on the interpreter.
I meant like, while using this PR, not that is has been fixed. Sorry if it was misunderstood. But if it's not mention on the PR maybe the thing it needs it's not here by this initial implementation. |
Driv3r seemed fine when it was tested, Stuntman NTSC is a lot better but still can "slightly" deviate. I suspect it is once again, the interpreter rounding/clamping values somewhere. |
@AmyRoxwell Ah, I understand you now. That's great news. @GitHubProUser67 Thanks, nice to see Driv3r is looking better. Would it make sense to list these games in your OP? |
That was the plan as far as I know. Probably someone underestimated how important 1:1 implementation was to keep compatibility. PS3 CELL implemented special Altivec/VMX mode to make PPE core vector floats compatible with SPU, but also with PS2 emulation in mind. Later it turned out that they really miscalculated importance of accurate floating point math in PS2 emulation. To the point that first fixes in ~2008-2010 were strictly per game, like "on this pc, add 0x01 to this reg, and get back execution to recompiler". Soft floats, including accurate DIV, came later, when new people were hired. :) In the end only VU1 is using real SPE, everything else use PPE VMX compatibility mode.
And that's indeed a great outcome. Nice work. :) |
Thank you Goatman13! The PCSX2 team also gets massive credits here for their help and support, of course the goal is to be PS2 perfect on this one. There is this one game, Mortal Combat Shaolin Monks which doesn't work fully yet on the Soft-Float div due to the game doing loads of Log2 on top of existing Log2 results, leading to it relying on rounding in booth directions... |
…eed-up simple calculations. This greatly improves performance while using Soft-Floats.
dca7e3c
to
745e474
Compare
BTW the reason macOS builds are failing is they have PCH off, which means you don't get a bunch of headers auto-included. In particular, you need an |
…s to their respectives place. I don't like the SIMD way of doing it, it can be slower and less practical to use (expensive casting).
Now the only code style remaining is the Global VU TMP. |
common/BitUtils.h
Outdated
for (s32 i = 31; i >= 0; i--) | ||
{ | ||
if (((value >> i) & 1) != 0) | ||
return i; | ||
} | ||
return -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (s32 i = 31; i >= 0; i--) | |
{ | |
if (((value >> i) & 1) != 0) | |
return i; | |
} | |
return -1; | |
#ifdef _MSC_VER | |
unsigned long bit; | |
return _BitScanReverse(&bit, value) ? bit : -1; | |
#else | |
return value ? __builtin_clz(value) ^ 31 : -1; | |
#endif |
And you can drop the rest of the changes and make BitScanReverse8 and clz just call this (or pick one and stop using the rest).
As a side note, not handling the value == 0 case will be a bit cheaper, and in my experience in pretty much all cases, the caller has already checked and is only calling this if they know value
is nonzero, so the separate check here is just wasted cycles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I will do that when possible and push, I admit I lacked experience with the BitScan part.
I declare Final Fantasy X fixed on PCSX2! GT4/Tourist Trophy are an edge case that we can hopefully sort out soon. |
d1282ec
to
5b94f53
Compare
…ftfloat on some extra obscure VU ops and fixes a denormals check on the checkDivideByZero method in the FPU. Fixes: - Final Fantasy X (fully playable) - Klonoa 2 Partially Fixes: - Mortal combat Shaloin Monks - Gran Turismo 4 (game patch will be neceassary to skip Licence Test CRC check). - Tourist Trophy (game patch will be neceassary to skip Licence Test CRC check). The stop gap div measure is not yet enough to fully fix GT4/TouristTrophy (they will need different rounding modes per licences). Currently this is bridged on the Div Rounding Mode setting.
Hopefully This could someday get implemented into the recompiler. Having this many games fixes (And some outright going from broken to playable) is really nice to see! Keep up the great work you doing! |
Superman Returns Colin McRae Rally 3 |
so this PR does not fix the bugs in Colin McRae Rally 3, correct? |
Correct. Even tried with EE Cache and full floats, no dice. |
either floating point needs to be perfect or it’s a timing issue |
For FFX, the boss turning invisible bug doesn't happen when using the interpreter, but it doesn't seem to be affected by soft floats, and seems to be a regression, this will have to be re tested on the recompiler. |
…lags + uses built-in clz for Add/Sub. Fixes a TON of games. The flags are not yet in use in the Interpreters, this will ideally be commited next (requires VU code changes). The Div/Sqrt method is unoptimized for now, the team is working on a faster equivalent.
And there we have our New-Year present! Fully accurate FPU in PCSX2! Aside a few things remaining to adjust (flags and newer Div/Sqrt method), we now have a solid basis that replicate the PS2 operations. The last commit fixes:
|
Jesus. This is amazing. many of the oldest issues are suddenly just fixed. This is truly God's work you and Tellow and everyone else has done here. |
Tested Colin McRae Rally 3 with this commit and the AI still goes out of sync and crashes into walls. What I should also add is that the AI keeps accelerating against the wall, then it "reminds" it could reverse as I can see it tries to back out from the wall, but it stays in place and goes nowhere. After almost 3 minutes, the AI "dies", as it probably thought it has finished the race. |
@LoStraniero91 |
You can download it yourself from the artifacts right below the comments. |
You only need a GitHub account to download the CI artifacts. And you can download it from here EDIT: |
Wonderful :O, I look forward to them soon being able to repair driver 3, it makes me want to play it again :D |
Demo replays of Tokyo Xtreme Racer 0 are MUCH closer to the ones running on console than ever! |
We use a faster checked method that achieve the same result.
41f561b
to
99ee5d5
Compare
This Pull Request implements the first take ever on real Soft-Float support in PCSX2.
This work is a combination or several efforts and researches done prior.
Credits:
https://www.gregorygaines.com/blog/emulating-ps2-floating-point-nums-ieee-754-diffs-part-1/
https://github.com/assumenothing/Tommunism.SoftFloat/tree/main
https://github.com/GitHubProUser67/MultiServer3/blob/main/BackendServices/CastleLibrary/EmotionEngine.Emulator/Ps2Float.cs
https://github.com/Goatman13/pcsx2/tree/accurate_int_add_sub
PCSX2 Team for their help and support in this massive journey.
This pull request should be tested with every games requiring a clamping/rounding mode/float patches (cf: GameDatabase).
Currently, this PR fixes on the interpreters:
[BUG]: DJbox (Japan) - SCPS-15082 - 56275BE9 #5169
Ratchet & Clank 2 - Megaturret Doesn't Work Correctly #354
[BUG]: Tourist Trophy: License Tests are broken and not completeable, player is placed out of bounds #11507
[BUG]: Monster Hunter games: bounce calculation inaccuracy #10519
[BUG]: Opening demo desyncs. The Taxi 2 (SLPS-20478) #8068
[BUG]: Pride FC - Fighting Championship | Missing text and textures in Hardware and Software render modes. #7642
[BUG]: Jak & Daxter/Jak 3 -- Character slides on his own | Jak 2 -- Inclined Camera Drift #5257
[BUG]: Final Fantasy X Tidus Falls Through Lift #8228
[REGRESSION]: Final Fantasy X Bosses Turn Invisible During Death Animation #8595
[Feature Request]: Final Fantasy X GameDB Config #10885
[BUG]: Driv3r - Bizarre AI (?) problem: impossible to pass "Lead On Baccus" mission (the 2nd mission) #11714
[BUG]: Camera is static in Prince of Persia: Warrior Within menu #5070
[BUG] World Series of Poker 2008 - Battle for the Bracelets: Broken character geometry #4546
Meta: Games that don't like the Full fpu mode. #2245
[BUG]: FPU rounding issues in Shadow of the Colossus (SCUS-97472) #11528
[BUG]: Tourist Trophy: License Tests are broken and not completeable, player is placed out of bounds #11507
[BUG]: Disney's UP TLB Miss #4760
[BUG]: Need for Speed Undercover not loading save games properly unless they’re created within PCSX2 #9831
Gran Turismo 4 license tests
Mortal Combat Shaolin Monks
Tokyo Xtreme Racer Zero (Accurate Mul/Div for the EE FPU)
Any other games using the NegDiv hack or any other FPU rounding mode.
This sets the floor for Soft-Float in PCSX2, a long awaited contribution.