Skip to content

Commit de047ea

Browse files
[Soft-Float] - Initial Interpreter Implementation of Ps2's floating point 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: - #354 - #11507 - #10519 - #8068 - #7642 - #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.
1 parent eeb9193 commit de047ea

14 files changed

+2207
-655
lines changed

pcsx2-qt/Settings/AdvancedSettingsWidget.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ AdvancedSettingsWidget::AdvancedSettingsWidget(SettingsWindow* dialog, QWidget*
4848
connect(m_ui.vu0ClampMode, QOverload<int>::of(&QComboBox::currentIndexChanged), [this](int index) { setClampingMode(0, index); });
4949
connect(m_ui.vu1ClampMode, QOverload<int>::of(&QComboBox::currentIndexChanged), [this](int index) { setClampingMode(1, index); });
5050

51+
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.eeSoftAddSub, "EmuCore/CPU/Recompiler", "fpuSoftAddSub", false);
52+
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.eeSoftMulDiv, "EmuCore/CPU/Recompiler", "fpuSoftMulDiv", false);
53+
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.eeSoftSqrt, "EmuCore/CPU/Recompiler", "fpuSoftSqrt", false);
54+
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.vu0SoftAddSub, "EmuCore/CPU/Recompiler", "vu0SoftAddSub", false);
55+
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.vu0SoftMulDiv, "EmuCore/CPU/Recompiler", "vu0SoftMulDiv", false);
56+
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.vu0SoftSqrt, "EmuCore/CPU/Recompiler", "vu0SoftSqrt", false);
57+
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.vu1SoftAddSub, "EmuCore/CPU/Recompiler", "vu1SoftAddSub", false);
58+
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.vu1SoftMulDiv, "EmuCore/CPU/Recompiler", "vu1SoftMulDiv", false);
59+
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.vu1SoftSqrt, "EmuCore/CPU/Recompiler", "vu1SoftSqrt", false);
60+
5161
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.iopRecompiler, "EmuCore/CPU/Recompiler", "EnableIOP", true);
5262

5363
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.gameFixes, "EmuCore", "EnableGameFixes", true);

pcsx2-qt/Settings/AdvancedSettingsWidget.ui

Lines changed: 192 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
<rect>
3434
<x>0</x>
3535
<y>-447</y>
36-
<width>790</width>
37-
<height>1049</height>
36+
<width>793</width>
37+
<height>1283</height>
3838
</rect>
3939
</property>
4040
<layout class="QVBoxLayout" name="verticalLayout">
@@ -94,10 +94,10 @@
9494
</item>
9595
</widget>
9696
</item>
97-
<item row="1" column="0">
98-
<widget class="QLabel" name="eeDivRoundingLabel">
97+
<item row="2" column="0">
98+
<widget class="QLabel" name="eeClampLabel">
9999
<property name="text">
100-
<string extracomment="Rounding refers here to the mathematical term.">Division Rounding Mode:</string>
100+
<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>
101101
</property>
102102
</widget>
103103
</item>
@@ -125,38 +125,7 @@
125125
</item>
126126
</widget>
127127
</item>
128-
<item row="2" column="0">
129-
<widget class="QLabel" name="eeClampLabel">
130-
<property name="text">
131-
<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>
132-
</property>
133-
</widget>
134-
</item>
135-
<item row="2" column="1">
136-
<widget class="QComboBox" name="eeClampMode">
137-
<item>
138-
<property name="text">
139-
<string comment="ClampMode">None</string>
140-
</property>
141-
</item>
142-
<item>
143-
<property name="text">
144-
<string>Normal (Default)</string>
145-
</property>
146-
</item>
147-
<item>
148-
<property name="text">
149-
<string extracomment="Sign: refers here to the mathematical meaning (plus/minus).">Extra + Preserve Sign</string>
150-
</property>
151-
</item>
152-
<item>
153-
<property name="text">
154-
<string>Full</string>
155-
</property>
156-
</item>
157-
</widget>
158-
</item>
159-
<item row="3" column="0" colspan="2">
128+
<item row="4" column="0" colspan="2">
160129
<layout class="QGridLayout" name="eeSettingsMisc">
161130
<item row="1" column="0">
162131
<widget class="QCheckBox" name="eeWaitLoopDetection">
@@ -208,6 +177,67 @@
208177
</widget>
209178
</item>
210179
</layout>
180+
</item>
181+
<item row="2" column="1">
182+
<widget class="QComboBox" name="eeClampMode">
183+
<item>
184+
<property name="text">
185+
<string comment="ClampMode">None</string>
186+
</property>
187+
</item>
188+
<item>
189+
<property name="text">
190+
<string>Normal (Default)</string>
191+
</property>
192+
</item>
193+
<item>
194+
<property name="text">
195+
<string extracomment="Sign: refers here to the mathematical meaning (plus/minus).">Extra + Preserve Sign</string>
196+
</property>
197+
</item>
198+
<item>
199+
<property name="text">
200+
<string>Full</string>
201+
</property>
202+
</item>
203+
</widget>
204+
</item>
205+
<item row="1" column="0">
206+
<widget class="QLabel" name="eeDivRoundingLabel">
207+
<property name="text">
208+
<string extracomment="Rounding refers here to the mathematical term.">Division Rounding Mode:</string>
209+
</property>
210+
</widget>
211+
</item>
212+
<item row="3" column="0" colspan="2">
213+
<widget class="QGroupBox" name="eeSoftFloat">
214+
<property name="title">
215+
<string>Software Float</string>
216+
</property>
217+
<layout class="QGridLayout" name="gridLayout_4">
218+
<item row="0" column="1">
219+
<widget class="QCheckBox" name="eeSoftMulDiv">
220+
<property name="text">
221+
<string>Multiplication/Division</string>
222+
</property>
223+
</widget>
224+
</item>
225+
<item row="0" column="0">
226+
<widget class="QCheckBox" name="eeSoftAddSub">
227+
<property name="text">
228+
<string>Addition/Subtraction</string>
229+
</property>
230+
</widget>
231+
</item>
232+
<item row="1" column="0">
233+
<widget class="QCheckBox" name="eeSoftSqrt">
234+
<property name="text">
235+
<string>Square Root</string>
236+
</property>
237+
</widget>
238+
</item>
239+
</layout>
240+
</widget>
211241
</item>
212242
</layout>
213243
</widget>
@@ -218,7 +248,7 @@
218248
<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>
219249
</property>
220250
<layout class="QGridLayout" name="gridLayout_3">
221-
<item row="2" column="0">
251+
<item row="3" column="0">
222252
<widget class="QLabel" name="vu1RoundingLabel">
223253
<property name="text">
224254
<string>VU1 Rounding Mode:</string>
@@ -249,7 +279,129 @@
249279
</item>
250280
</widget>
251281
</item>
252-
<item row="4" column="0" colspan="2">
282+
<item row="4" column="0">
283+
<widget class="QLabel" name="vu1ClampLabel">
284+
<property name="text">
285+
<string>VU1 Clamping Mode:</string>
286+
</property>
287+
</widget>
288+
</item>
289+
<item row="0" column="0">
290+
<widget class="QLabel" name="vu0RoundingLabel">
291+
<property name="text">
292+
<string>VU0 Rounding Mode:</string>
293+
</property>
294+
</widget>
295+
</item>
296+
<item row="5" column="0" colspan="2">
297+
<widget class="QGroupBox" name="vu1SoftFloat">
298+
<property name="title">
299+
<string>VU1 Software Float</string>
300+
</property>
301+
<layout class="QGridLayout" name="gridLayout_8">
302+
<item row="0" column="1">
303+
<widget class="QCheckBox" name="vu1SoftMulDiv">
304+
<property name="text">
305+
<string>Multiplication/Division</string>
306+
</property>
307+
</widget>
308+
</item>
309+
<item row="0" column="0">
310+
<widget class="QCheckBox" name="vu1SoftAddSub">
311+
<property name="text">
312+
<string>Addition/Subtraction</string>
313+
</property>
314+
</widget>
315+
</item>
316+
<item row="1" column="0">
317+
<widget class="QCheckBox" name="vu1SoftSqrt">
318+
<property name="text">
319+
<string>Float Square Root</string>
320+
</property>
321+
</widget>
322+
</item>
323+
</layout>
324+
</widget>
325+
</item>
326+
<item row="2" column="0" colspan="2">
327+
<widget class="QGroupBox" name="vu0SoftFloat">
328+
<property name="title">
329+
<string>VU0 Software Float</string>
330+
</property>
331+
<layout class="QGridLayout" name="gridLayout_6">
332+
<item row="0" column="1">
333+
<widget class="QCheckBox" name="vu0SoftMulDiv">
334+
<property name="text">
335+
<string>Multiplication/Division</string>
336+
</property>
337+
</widget>
338+
</item>
339+
<item row="0" column="0">
340+
<widget class="QCheckBox" name="vu0SoftAddSub">
341+
<property name="text">
342+
<string>Addition/Subtraction</string>
343+
</property>
344+
</widget>
345+
</item>
346+
<item row="1" column="0">
347+
<widget class="QCheckBox" name="vu0SoftSqrt">
348+
<property name="text">
349+
<string>Square Root</string>
350+
</property>
351+
</widget>
352+
</item>
353+
</layout>
354+
</widget>
355+
</item>
356+
<item row="3" column="1">
357+
<widget class="QComboBox" name="vu1RoundingMode">
358+
<item>
359+
<property name="text">
360+
<string>Nearest</string>
361+
</property>
362+
</item>
363+
<item>
364+
<property name="text">
365+
<string>Negative</string>
366+
</property>
367+
</item>
368+
<item>
369+
<property name="text">
370+
<string>Positive</string>
371+
</property>
372+
</item>
373+
<item>
374+
<property name="text">
375+
<string>Chop/Zero (Default)</string>
376+
</property>
377+
</item>
378+
</widget>
379+
</item>
380+
<item row="1" column="1">
381+
<widget class="QComboBox" name="vu0ClampMode">
382+
<item>
383+
<property name="text">
384+
<string>None</string>
385+
</property>
386+
</item>
387+
<item>
388+
<property name="text">
389+
<string>Normal (Default)</string>
390+
</property>
391+
</item>
392+
<item>
393+
<property name="text">
394+
<string>Extra</string>
395+
</property>
396+
</item>
397+
<item>
398+
<property name="text">
399+
<string>Extra + Preserve Sign</string>
400+
</property>
401+
</item>
402+
</widget>
403+
</item>
404+
<item row="6" column="0" colspan="2">
253405
<layout class="QGridLayout" name="vuSettingsLayout">
254406
<item row="1" column="0">
255407
<widget class="QCheckBox" name="vuFlagHack">
@@ -281,76 +433,14 @@
281433
</item>
282434
</layout>
283435
</item>
284-
<item row="1" column="1">
285-
<widget class="QComboBox" name="vu0ClampMode">
286-
<item>
287-
<property name="text">
288-
<string>None</string>
289-
</property>
290-
</item>
291-
<item>
292-
<property name="text">
293-
<string>Normal (Default)</string>
294-
</property>
295-
</item>
296-
<item>
297-
<property name="text">
298-
<string>Extra</string>
299-
</property>
300-
</item>
301-
<item>
302-
<property name="text">
303-
<string>Extra + Preserve Sign</string>
304-
</property>
305-
</item>
306-
</widget>
307-
</item>
308436
<item row="1" column="0">
309437
<widget class="QLabel" name="vu0ClampLabel">
310438
<property name="text">
311439
<string>VU0 Clamping Mode:</string>
312440
</property>
313441
</widget>
314442
</item>
315-
<item row="0" column="0">
316-
<widget class="QLabel" name="vu0RoundingLabel">
317-
<property name="text">
318-
<string>VU0 Rounding Mode:</string>
319-
</property>
320-
</widget>
321-
</item>
322-
<item row="3" column="0">
323-
<widget class="QLabel" name="vu1ClampLabel">
324-
<property name="text">
325-
<string>VU1 Clamping Mode:</string>
326-
</property>
327-
</widget>
328-
</item>
329-
<item row="2" column="1">
330-
<widget class="QComboBox" name="vu1RoundingMode">
331-
<item>
332-
<property name="text">
333-
<string>Nearest</string>
334-
</property>
335-
</item>
336-
<item>
337-
<property name="text">
338-
<string>Negative</string>
339-
</property>
340-
</item>
341-
<item>
342-
<property name="text">
343-
<string>Positive</string>
344-
</property>
345-
</item>
346-
<item>
347-
<property name="text">
348-
<string>Chop/Zero (Default)</string>
349-
</property>
350-
</item>
351-
</widget>
352-
</item>
353-
<item row="3" column="1">
443+
<item row="4" column="1">
354444
<widget class="QComboBox" name="vu1ClampMode">
355445
<item>
356446
<property name="text">

pcsx2/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ set(pcsx2Sources
9393
MTGS.cpp
9494
MTVU.cpp
9595
Patch.cpp
96+
Ps2Float.cpp
9697
Pcsx2Config.cpp
9798
PerformanceMetrics.cpp
9899
PrecompiledHeader.cpp
@@ -173,6 +174,7 @@ set(pcsx2Headers
173174
MTVU.h
174175
Memory.h
175176
MemoryTypes.h
177+
Ps2Float.h
176178
Patch.h
177179
PerformanceMetrics.h
178180
PrecompiledHeader.h

0 commit comments

Comments
 (0)