Skip to content
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

FPU: Removed forced rounding on DIV/SQRT/RSQRT (Do Not merge!) #3816

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bin/GameIndex.dbf
Original file line number Diff line number Diff line change
Expand Up @@ -14612,10 +14612,12 @@ vuRoundMode = 0 // Fixes textures and crashes.
Serial = SLES-53524
Name = Mortal Kombat - Shaolin Monks
Region = PAL-M5
eeRoundMode = 2 // Fixes texture sizes
---------------------------------------------
Serial = SLES-53525
Name = Mortal Kombat - Shaolin Monks
Region = PAL-G
eeRoundMode = 2 // Fixes texture sizes
---------------------------------------------
Serial = SLES-53526
Name = Suffering, The - Ties that Bind
Expand Down Expand Up @@ -40239,6 +40241,7 @@ Serial = SLUS-21087
Name = Mortal Kombat - Shaolin Monks
Region = NTSC-U
Compat = 5
eeRoundMode = 2 // Fixes texture sizes
---------------------------------------------
Serial = SLUS-21088
Name = Disney's Chicken Little
Expand Down
25 changes: 0 additions & 25 deletions pcsx2/x86/iFPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1028,19 +1028,6 @@ void recDIV_S_xmm(int info)
roundmodeFlag = true;
}
}
else
{
if (g_sseMXCSR.GetRoundMode() != SSEround_Nearest)
{
// Set roundmode to nearest since it isn't already
//Console.WriteLn("div to nearest");

roundmode_nearest = g_sseMXCSR;
roundmode_nearest.SetRoundMode( SSEround_Nearest );
xLDMXCSR( roundmode_nearest );
roundmodeFlag = true;
}
}

switch(info & (PROCESS_EE_S|PROCESS_EE_T) ) {
case PROCESS_EE_S:
Expand Down Expand Up @@ -1600,16 +1587,6 @@ void recSQRT_S_xmm(int info)
bool roundmodeFlag = false;
//Console.WriteLn("FPU: SQRT");

if (g_sseMXCSR.GetRoundMode() != SSEround_Nearest)
{
// Set roundmode to nearest if it isn't already
//Console.WriteLn("sqrt to nearest");
roundmode_nearest = g_sseMXCSR;
roundmode_nearest.SetRoundMode( SSEround_Nearest );
xLDMXCSR (roundmode_nearest);
roundmodeFlag = true;
}

if( info & PROCESS_EE_T ) xMOVSS(xRegisterSSE(EEREC_D), xRegisterSSE(EEREC_T));
else xMOVSSZX(xRegisterSSE(EEREC_D), ptr[&fpuRegs.fpr[_Ft_]]);

Expand All @@ -1633,8 +1610,6 @@ void recSQRT_S_xmm(int info)
if (CHECK_FPU_OVERFLOW) xMIN.SS(xRegisterSSE(EEREC_D), ptr[&g_maxvals[0]]);// Only need to do positive clamp, since EEREC_D is positive
xSQRT.SS(xRegisterSSE(EEREC_D), xRegisterSSE(EEREC_D));
if (CHECK_FPU_EXTRA_OVERFLOW) ClampValues(EEREC_D); // Shouldn't need to clamp again since SQRT of a number will always be smaller than the original number, doing it just incase :/

if (roundmodeFlag) xLDMXCSR (g_sseMXCSR);
}

FPURECOMPILE_CONSTCODE(SQRT_S, XMMINFO_WRITED|XMMINFO_READT);
Expand Down
43 changes: 1 addition & 42 deletions pcsx2/x86/iFPUd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -652,20 +652,7 @@ void recDIV_S_xmm(int info)
roundmodeFlag = true;
}
}
else
{
if (g_sseMXCSR.GetRoundMode() != SSEround_Nearest)
{
// Set roundmode to nearest since it isn't already
//Console.WriteLn("div to nearest");

roundmode_nearest = g_sseMXCSR;
roundmode_nearest.SetRoundMode( SSEround_Nearest );
xLDMXCSR( roundmode_nearest );
roundmodeFlag = true;
}
}


int sreg, treg;

ALLOC_S(sreg); ALLOC_T(treg);
Expand Down Expand Up @@ -927,21 +914,10 @@ void recSQRT_S_xmm(int info)
{
EE::Profiler.EmitOp(eeOpcode::SQRT_F);
u8 *pjmp;
int roundmodeFlag = 0;
int tempReg = _allocX86reg(xEmptyReg, X86TYPE_TEMP, 0, 0);
int t1reg = _allocTempXMMreg(XMMT_FPS, -1);
//Console.WriteLn("FPU: SQRT");

if (g_sseMXCSR.GetRoundMode() != SSEround_Nearest)
{
// Set roundmode to nearest if it isn't already
//Console.WriteLn("sqrt to nearest");
roundmode_nearest = g_sseMXCSR;
roundmode_nearest.SetRoundMode( SSEround_Nearest );
xLDMXCSR (roundmode_nearest);
roundmodeFlag = 1;
}

GET_T(EEREC_D);

if (FPU_FLAGS_ID) {
Expand All @@ -967,10 +943,6 @@ void recSQRT_S_xmm(int info)

ToPS2FPU(EEREC_D, false, t1reg, false);

if (roundmodeFlag == 1) {
xLDMXCSR (g_sseMXCSR);
}

_freeX86reg(tempReg);
_freeXMMreg(t1reg);
}
Expand Down Expand Up @@ -1056,17 +1028,6 @@ void recRSQRT_S_xmm(int info)
// Should this do the same? or is changing the roundmode to nearest the better
// behavior for both recs? --air

bool roundmodeFlag = false;
if (g_sseMXCSR.GetRoundMode() != SSEround_Nearest)
{
// Set roundmode to nearest if it isn't already
//Console.WriteLn("sqrt to nearest");
roundmode_nearest = g_sseMXCSR;
roundmode_nearest.SetRoundMode( SSEround_Nearest );
xLDMXCSR (roundmode_nearest);
roundmodeFlag = true;
}

ALLOC_S(sreg); ALLOC_T(treg);

if (FPU_FLAGS_ID)
Expand All @@ -1077,8 +1038,6 @@ void recRSQRT_S_xmm(int info)
xMOVSS(xRegisterSSE(EEREC_D), xRegisterSSE(sreg));

_freeXMMreg(treg); _freeXMMreg(sreg);

if (roundmodeFlag) xLDMXCSR (g_sseMXCSR);
}

FPURECOMPILE_CONSTCODE(RSQRT_S, XMMINFO_WRITED|XMMINFO_READS|XMMINFO_READT);
Expand Down