Skip to content

Commit

Permalink
GameSettings: Add PGXP projection precision
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Feb 17, 2021
1 parent db4f521 commit e7b9309
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
activity.createBooleanGameSetting(ps, "GPUForceNTSCTimings", R.string.settings_force_ntsc_timings);
activity.createBooleanGameSetting(ps, "GPUWidescreenHack", R.string.settings_widescreen_hack);
activity.createBooleanGameSetting(ps, "GPUPGXP", R.string.settings_pgxp_geometry_correction);
activity.createBooleanGameSetting(ps, "PGXPPreserveProjFP", R.string.settings_pgxp_preserve_projection_precision);
activity.createBooleanGameSetting(ps, "GPUPGXPDepthBuffer", R.string.settings_pgxp_depth_buffer);

setPreferenceScreen(ps);
Expand Down
2 changes: 2 additions & 0 deletions src/duckstation-qt/gamepropertiesdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ void GamePropertiesDialog::populateGameSettings()
populateBooleanUserSetting(m_ui.userWidescreenHack, gs.gpu_widescreen_hack);
populateBooleanUserSetting(m_ui.userForce43For24Bit, gs.display_force_4_3_for_24bit);
populateBooleanUserSetting(m_ui.userPGXP, gs.gpu_pgxp);
populateBooleanUserSetting(m_ui.userPGXPProjectionPrecision, gs.gpu_pgxp_projection_precision);
populateBooleanUserSetting(m_ui.userPGXPDepthBuffer, gs.gpu_pgxp_depth_buffer);

if (gs.controller_1_type.has_value())
Expand Down Expand Up @@ -601,6 +602,7 @@ void GamePropertiesDialog::connectUi()
connectBooleanUserSetting(m_ui.userWidescreenHack, &m_game_settings.gpu_widescreen_hack);
connectBooleanUserSetting(m_ui.userForce43For24Bit, &m_game_settings.display_force_4_3_for_24bit);
connectBooleanUserSetting(m_ui.userPGXP, &m_game_settings.gpu_pgxp);
connectBooleanUserSetting(m_ui.userPGXPProjectionPrecision, &m_game_settings.gpu_pgxp_projection_precision);
connectBooleanUserSetting(m_ui.userPGXPDepthBuffer, &m_game_settings.gpu_pgxp_depth_buffer);

connect(m_ui.userControllerType1, QOverload<int>::of(&QComboBox::currentIndexChanged), [this](int index) {
Expand Down
10 changes: 10 additions & 0 deletions src/duckstation-qt/gamepropertiesdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,16 @@
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="userPGXPProjectionPrecision">
<property name="text">
<string>PGXP Preserve Projection Precision</string>
</property>
<property name="tristate">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="userPGXPDepthBuffer">
<property name="text">
<string>PGXP Depth Buffer</string>
Expand Down
2 changes: 1 addition & 1 deletion src/frontend-common/game_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class GameList
enum : u32
{
GAME_LIST_CACHE_SIGNATURE = 0x45434C47,
GAME_LIST_CACHE_VERSION = 22
GAME_LIST_CACHE_VERSION = 23
};

using DatabaseMap = std::unordered_map<std::string, GameListDatabaseEntry>;
Expand Down
37 changes: 30 additions & 7 deletions src/frontend-common/game_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,10 @@ bool Entry::LoadFromStream(ByteStream* stream)
!ReadOptionalFromStream(stream, &gpu_scaled_dithering) ||
!ReadOptionalFromStream(stream, &gpu_force_ntsc_timings) ||
!ReadOptionalFromStream(stream, &gpu_texture_filter) || !ReadOptionalFromStream(stream, &gpu_widescreen_hack) ||
!ReadOptionalFromStream(stream, &gpu_pgxp) || !ReadOptionalFromStream(stream, &gpu_pgxp_depth_buffer) ||
!ReadOptionalFromStream(stream, &controller_1_type) || !ReadOptionalFromStream(stream, &controller_2_type) ||
!ReadOptionalFromStream(stream, &memory_card_1_type) || !ReadOptionalFromStream(stream, &memory_card_2_type) ||
!ReadOptionalFromStream(stream, &gpu_pgxp) || !ReadOptionalFromStream(stream, &gpu_pgxp_projection_precision) ||
!ReadOptionalFromStream(stream, &gpu_pgxp_depth_buffer) || !ReadOptionalFromStream(stream, &controller_1_type) ||
!ReadOptionalFromStream(stream, &controller_2_type) || !ReadOptionalFromStream(stream, &memory_card_1_type) ||
!ReadOptionalFromStream(stream, &memory_card_2_type) ||
!ReadStringFromStream(stream, &memory_card_1_shared_path) ||
!ReadStringFromStream(stream, &memory_card_2_shared_path) || !ReadStringFromStream(stream, &input_profile_name))
{
Expand Down Expand Up @@ -176,10 +177,10 @@ bool Entry::SaveToStream(ByteStream* stream) const
WriteOptionalToStream(stream, gpu_per_sample_shading) && WriteOptionalToStream(stream, gpu_true_color) &&
WriteOptionalToStream(stream, gpu_scaled_dithering) && WriteOptionalToStream(stream, gpu_force_ntsc_timings) &&
WriteOptionalToStream(stream, gpu_texture_filter) && WriteOptionalToStream(stream, gpu_widescreen_hack) &&
WriteOptionalToStream(stream, gpu_pgxp) && WriteOptionalToStream(stream, gpu_pgxp_depth_buffer) &&
WriteOptionalToStream(stream, controller_1_type) && WriteOptionalToStream(stream, controller_2_type) &&
WriteOptionalToStream(stream, memory_card_1_type) && WriteOptionalToStream(stream, memory_card_2_type) &&
WriteStringToStream(stream, memory_card_1_shared_path) &&
WriteOptionalToStream(stream, gpu_pgxp) && WriteOptionalToStream(stream, gpu_pgxp_projection_precision) &&
WriteOptionalToStream(stream, gpu_pgxp_depth_buffer) && WriteOptionalToStream(stream, controller_1_type) &&
WriteOptionalToStream(stream, controller_2_type) && WriteOptionalToStream(stream, memory_card_1_type) &&
WriteOptionalToStream(stream, memory_card_2_type) && WriteStringToStream(stream, memory_card_1_shared_path) &&
WriteStringToStream(stream, memory_card_2_shared_path) && WriteStringToStream(stream, input_profile_name);
}

Expand Down Expand Up @@ -286,6 +287,9 @@ static void ParseIniSection(Entry* entry, const char* section, const CSimpleIniA
cvalue = ini.GetValue(section, "GPUPGXP", nullptr);
if (cvalue)
entry->gpu_pgxp = StringUtil::FromChars<bool>(cvalue);
cvalue = ini.GetValue(section, "GPUPGXPPreserveProjFP", nullptr);
if (cvalue)
entry->gpu_pgxp_projection_precision = StringUtil::FromChars<bool>(cvalue);
cvalue = ini.GetValue(section, "GPUPGXPDepthBuffer", nullptr);
if (cvalue)
entry->gpu_pgxp_depth_buffer = StringUtil::FromChars<bool>(cvalue);
Expand Down Expand Up @@ -392,6 +396,8 @@ static void StoreIniSection(const Entry& entry, const char* section, CSimpleIniA
ini.SetValue(section, "GPUWidescreenHack", entry.gpu_widescreen_hack.value() ? "true" : "false");
if (entry.gpu_pgxp.has_value())
ini.SetValue(section, "GPUPGXP", entry.gpu_pgxp.value() ? "true" : "false");
if (entry.gpu_pgxp_projection_precision.has_value())
ini.SetValue(section, "GPUPGXPPreserveProjFP", entry.gpu_pgxp_projection_precision.value() ? "true" : "false");
if (entry.gpu_pgxp_depth_buffer.has_value())
ini.SetValue(section, "GPUPGXPDepthBuffer", entry.gpu_pgxp_depth_buffer.value() ? "true" : "false");

Expand Down Expand Up @@ -440,6 +446,7 @@ u32 Entry::GetUserSettingsCount() const
count += BoolToUInt32(gpu_texture_filter.has_value());
count += BoolToUInt32(gpu_widescreen_hack.has_value());
count += BoolToUInt32(gpu_pgxp.has_value());
count += BoolToUInt32(gpu_pgxp_projection_precision.has_value());
count += BoolToUInt32(gpu_pgxp_depth_buffer.has_value());
count += BoolToUInt32(controller_1_type.has_value());
count += BoolToUInt32(controller_2_type.has_value());
Expand Down Expand Up @@ -579,6 +586,13 @@ static std::optional<std::string> GetEntryValueForKey(const Entry& entry, const
else
return entry.gpu_pgxp.value() ? "true" : "false";
}
else if (key == "GPUPGXPPreserveProjFP")
{
if (!entry.gpu_pgxp_projection_precision.has_value())
return std::nullopt;
else
return entry.gpu_pgxp_projection_precision.value() ? "true" : "false";
}
else if (key == "GPUPGXPDepthBuffer")
{
if (!entry.gpu_pgxp_depth_buffer.has_value())
Expand Down Expand Up @@ -789,6 +803,13 @@ static void SetEntryValueForKey(Entry& entry, const std::string_view& key, const
else
entry.gpu_pgxp = StringUtil::FromChars<bool>(value.value()).value_or(false);
}
else if (key == "GPUPGXPPreserveProjFP")
{
if (!value.has_value())
entry.gpu_pgxp_projection_precision.reset();
else
entry.gpu_pgxp_projection_precision = StringUtil::FromChars<bool>(value.value()).value_or(false);
}
else if (key == "GPUPGXPDepthBuffer")
{
if (!value.has_value())
Expand Down Expand Up @@ -1021,6 +1042,8 @@ void Entry::ApplySettings(bool display_osd_messages) const
g_settings.gpu_widescreen_hack = gpu_widescreen_hack.value();
if (gpu_pgxp.has_value())
g_settings.gpu_pgxp_enable = gpu_pgxp.value();
if (gpu_pgxp_projection_precision.has_value())
g_settings.gpu_pgxp_preserve_proj_fp = gpu_pgxp_projection_precision.value();
if (gpu_pgxp_depth_buffer.has_value())
g_settings.gpu_pgxp_depth_buffer = gpu_pgxp_depth_buffer.value();

Expand Down
1 change: 1 addition & 0 deletions src/frontend-common/game_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ struct Entry
std::optional<GPUTextureFilter> gpu_texture_filter;
std::optional<bool> gpu_widescreen_hack;
std::optional<bool> gpu_pgxp;
std::optional<bool> gpu_pgxp_projection_precision;
std::optional<bool> gpu_pgxp_depth_buffer;
std::optional<ControllerType> controller_1_type;
std::optional<ControllerType> controller_2_type;
Expand Down

0 comments on commit e7b9309

Please sign in to comment.