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

[Soft-Float] - Initial Interpreter Implementation of Ps2's floating point unit specification #12001

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
de047ea
[Soft-Float] - Initial Interpreter Implementation of Ps2's floating p…
GitHubProUser67 Nov 12, 2024
b7f3806
[Soft-Float] - Fixes Tony Hawk Pro Skater 4 Mul issue.
GitHubProUser67 Nov 13, 2024
b09bfb0
[FPU] - Uses Soft-Float comparison.
GitHubProUser67 Nov 13, 2024
3bd88f7
[VUops] - Implements accurate SQRT/RSQRT + removal of TriAce hack.
GitHubProUser67 Nov 13, 2024
3fe4277
[Soft-Float] - Fixes Operand checking for denormals Add/Sub operations.
GitHubProUser67 Nov 16, 2024
d5e5028
[Soft-Float] - Removes "special" COP1 mode.
GitHubProUser67 Nov 16, 2024
98e3df3
[Soft-Float] - Implements fully accurate Mul operations.
GitHubProUser67 Nov 21, 2024
34753ae
Arrange code style to accommodate requested changes.
GitHubProUser67 Nov 21, 2024
b0b65fa
[Soft-Float] - Removes Div "special" normalization constant.
GitHubProUser67 Nov 21, 2024
8bc2ed9
[Soft-Float] - Code review Part1.
GitHubProUser67 Nov 23, 2024
745e474
[Soft-Float] - Improves the PS2Float class by using a raw float to sp…
GitHubProUser67 Dec 7, 2024
5b94f53
[Soft-Float] - Fixes MAC-OS compile error + moves the bitUtils method…
GitHubProUser67 Dec 19, 2024
0a8c545
[Soft-Float] - Implemented stop-gap Div rounding mode + implements so…
GitHubProUser67 Dec 27, 2024
dfb361d
[Soft-Float] - Implements fully accurate Div/Sqrt/Ftoi/Itof/U|O|I|D f…
GitHubProUser67 Jan 4, 2025
99ee5d5
[Soft-Float] - Fixes Itof method on Clang compiler.
GitHubProUser67 Jan 6, 2025
8914229
[Soft-Float] - Fixes Itof/Ftoi accuracy.
GitHubProUser67 Jan 19, 2025
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
18 changes: 18 additions & 0 deletions common/BitUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ static inline int _BitScanReverse(unsigned long* const Index, const unsigned lon

namespace Common
{
static constexpr s8 msb[256] = {
-1, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7};

static constexpr s32 normalizeAmounts[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 8, 8, 8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 24, 24, 24, 24, 24, 24, 24};

template <typename T>
static constexpr __fi bool IsAligned(T value, unsigned int alignment)
{
Expand Down Expand Up @@ -84,6 +97,11 @@ namespace Common
// Perform our count leading zero.
return std::countl_zero(static_cast<u32>(n));
}

__fi static s32 BitScanReverse8(s32 b)
{
return msb[b];
}
} // namespace Common

template <typename T>
Expand Down
10 changes: 10 additions & 0 deletions pcsx2-qt/Settings/AdvancedSettingsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ AdvancedSettingsWidget::AdvancedSettingsWidget(SettingsWindow* dialog, QWidget*
connect(m_ui.vu0ClampMode, QOverload<int>::of(&QComboBox::currentIndexChanged), [this](int index) { setClampingMode(0, index); });
connect(m_ui.vu1ClampMode, QOverload<int>::of(&QComboBox::currentIndexChanged), [this](int index) { setClampingMode(1, index); });

SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.eeSoftAddSub, "EmuCore/CPU/Recompiler", "fpuSoftAddSub", false);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.eeSoftMulDiv, "EmuCore/CPU/Recompiler", "fpuSoftMulDiv", false);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.eeSoftSqrt, "EmuCore/CPU/Recompiler", "fpuSoftSqrt", false);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.vu0SoftAddSub, "EmuCore/CPU/Recompiler", "vu0SoftAddSub", false);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.vu0SoftMulDiv, "EmuCore/CPU/Recompiler", "vu0SoftMulDiv", false);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.vu0SoftSqrt, "EmuCore/CPU/Recompiler", "vu0SoftSqrt", false);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.vu1SoftAddSub, "EmuCore/CPU/Recompiler", "vu1SoftAddSub", false);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.vu1SoftMulDiv, "EmuCore/CPU/Recompiler", "vu1SoftMulDiv", false);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.vu1SoftSqrt, "EmuCore/CPU/Recompiler", "vu1SoftSqrt", false);

SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.iopRecompiler, "EmuCore/CPU/Recompiler", "EnableIOP", true);

SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.gameFixes, "EmuCore", "EnableGameFixes", true);
Expand Down
292 changes: 191 additions & 101 deletions pcsx2-qt/Settings/AdvancedSettingsWidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<x>0</x>
<y>-447</y>
<width>790</width>
<height>1049</height>
<height>1283</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
Expand Down Expand Up @@ -94,10 +94,10 @@
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="eeDivRoundingLabel">
<item row="2" column="0">
<widget class="QLabel" name="eeClampLabel">
<property name="text">
<string extracomment="Rounding refers here to the mathematical term.">Division Rounding Mode:</string>
<string extracomment="Clamping: Forcing out of bounds things in bounds by changing them to the closest possible value. In this case, this refers to clamping large PS2 floating point values (which map to infinity or NaN in PCs' IEEE754 floats) to non-infinite ones.">Clamping Mode:</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -125,38 +125,7 @@
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="eeClampLabel">
<property name="text">
<string extracomment="Clamping: Forcing out of bounds things in bounds by changing them to the closest possible value. In this case, this refers to clamping large PS2 floating point values (which map to infinity or NaN in PCs' IEEE754 floats) to non-infinite ones.">Clamping Mode:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="eeClampMode">
<item>
<property name="text">
<string comment="ClampMode">None</string>
</property>
</item>
<item>
<property name="text">
<string>Normal (Default)</string>
</property>
</item>
<item>
<property name="text">
<string extracomment="Sign: refers here to the mathematical meaning (plus/minus).">Extra + Preserve Sign</string>
</property>
</item>
<item>
<property name="text">
<string>Full</string>
</property>
</item>
</widget>
</item>
<item row="3" column="0" colspan="2">
<item row="4" column="0" colspan="2">
<layout class="QGridLayout" name="eeSettingsMisc">
<item row="1" column="0">
<widget class="QCheckBox" name="eeWaitLoopDetection">
Expand Down Expand Up @@ -208,6 +177,67 @@
</widget>
</item>
</layout>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="eeClampMode">
<item>
<property name="text">
<string comment="ClampMode">None</string>
</property>
</item>
<item>
<property name="text">
<string>Normal (Default)</string>
</property>
</item>
<item>
<property name="text">
<string extracomment="Sign: refers here to the mathematical meaning (plus/minus).">Extra + Preserve Sign</string>
</property>
</item>
<item>
<property name="text">
<string>Full</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="eeDivRoundingLabel">
<property name="text">
<string extracomment="Rounding refers here to the mathematical term.">Division Rounding Mode:</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QGroupBox" name="eeSoftFloat">
<property name="title">
<string>Software Float</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="1">
<widget class="QCheckBox" name="eeSoftMulDiv">
<property name="text">
<string>Multiplication/Division</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="eeSoftAddSub">
<property name="text">
<string>Addition/Subtraction</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="eeSoftSqrt">
<property name="text">
<string>Square Root</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
Expand All @@ -218,7 +248,7 @@
<string extracomment="Vector Unit/VU: refers to two of PS2's processors. Do not translate the full text or do so as a comment. Leave the acronym as-is.">Vector Units (VU)</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="2" column="0">
<item row="3" column="0">
<widget class="QLabel" name="vu1RoundingLabel">
<property name="text">
<string>VU1 Rounding Mode:</string>
Expand Down Expand Up @@ -249,7 +279,129 @@
</item>
</widget>
</item>
<item row="4" column="0" colspan="2">
<item row="4" column="0">
<widget class="QLabel" name="vu1ClampLabel">
<property name="text">
<string>VU1 Clamping Mode:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="vu0RoundingLabel">
<property name="text">
<string>VU0 Rounding Mode:</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QGroupBox" name="vu1SoftFloat">
<property name="title">
<string>VU1 Software Float</string>
</property>
<layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="1">
<widget class="QCheckBox" name="vu1SoftMulDiv">
<property name="text">
<string>Multiplication/Division</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="vu1SoftAddSub">
<property name="text">
<string>Addition/Subtraction</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="vu1SoftSqrt">
<property name="text">
<string>Float Square Root</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QGroupBox" name="vu0SoftFloat">
<property name="title">
<string>VU0 Software Float</string>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="1">
<widget class="QCheckBox" name="vu0SoftMulDiv">
<property name="text">
<string>Multiplication/Division</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="vu0SoftAddSub">
<property name="text">
<string>Addition/Subtraction</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="vu0SoftSqrt">
<property name="text">
<string>Square Root</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="vu1RoundingMode">
<item>
<property name="text">
<string>Nearest</string>
</property>
</item>
<item>
<property name="text">
<string>Negative</string>
</property>
</item>
<item>
<property name="text">
<string>Positive</string>
</property>
</item>
<item>
<property name="text">
<string>Chop/Zero (Default)</string>
</property>
</item>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="vu0ClampMode">
<item>
<property name="text">
<string>None</string>
</property>
</item>
<item>
<property name="text">
<string>Normal (Default)</string>
</property>
</item>
<item>
<property name="text">
<string>Extra</string>
</property>
</item>
<item>
<property name="text">
<string>Extra + Preserve Sign</string>
</property>
</item>
</widget>
</item>
<item row="6" column="0" colspan="2">
<layout class="QGridLayout" name="vuSettingsLayout">
<item row="1" column="0">
<widget class="QCheckBox" name="vuFlagHack">
Expand Down Expand Up @@ -281,76 +433,14 @@
</item>
</layout>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="vu0ClampMode">
<item>
<property name="text">
<string>None</string>
</property>
</item>
<item>
<property name="text">
<string>Normal (Default)</string>
</property>
</item>
<item>
<property name="text">
<string>Extra</string>
</property>
</item>
<item>
<property name="text">
<string>Extra + Preserve Sign</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="vu0ClampLabel">
<property name="text">
<string>VU0 Clamping Mode:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="vu0RoundingLabel">
<property name="text">
<string>VU0 Rounding Mode:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="vu1ClampLabel">
<property name="text">
<string>VU1 Clamping Mode:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="vu1RoundingMode">
<item>
<property name="text">
<string>Nearest</string>
</property>
</item>
<item>
<property name="text">
<string>Negative</string>
</property>
</item>
<item>
<property name="text">
<string>Positive</string>
</property>
</item>
<item>
<property name="text">
<string>Chop/Zero (Default)</string>
</property>
</item>
</widget>
</item>
<item row="3" column="1">
<item row="4" column="1">
<widget class="QComboBox" name="vu1ClampMode">
<item>
<property name="text">
Expand Down
Loading
Loading