Frontends: Add PGXP Depth Buffer options

This commit is contained in:
Connor McLaughlin 2020-12-23 01:17:10 +10:00
parent d320d5c830
commit 744cfbd924
9 changed files with 140 additions and 52 deletions

View file

@ -106,6 +106,8 @@
<string name="settings_summary_pgxp_texture_correction">Uses perspective-correct interpolation for texture coordinates and colors, straightening out warped textures. Requires geometry correction enabled.</string>
<string name="settings_pgxp_preserve_projection_precision">PGXP Preserve Projection Precision</string>
<string name="settings_summary_pgxp_preserve_projection_precision">Enables additional precision for PGXP. May improve visuals in some games but break others.</string>
<string name="settings_pgxp_depth_buffer">PGXP Depth Buffer</string>
<string name="settings_summary_pgxp_depth_buffer">Attempts to reduce polygon Z-fighting by testing pixels against the depth values from PGXP. Low compatibility, but can work well in some games.</string>
<string name="menu_main_resume_last_session">Resume Last Session</string>
<string name="menu_main_start_file">Start File</string>
<string name="menu_main_start_bios">Start BIOS</string>

View file

@ -131,4 +131,11 @@
app:summary="@string/settings_summary_pgxp_preserve_projection_precision"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
app:key="GPU/PGXPDepthBuffer"
app:title="@string/settings_pgxp_depth_buffer"
app:defaultValue="false"
app:summary="@string/settings_summary_pgxp_depth_buffer"
app:iconSpaceReserved="false" />
</PreferenceScreen>

View file

@ -489,7 +489,7 @@ void LibretroHostInterface::OnSystemDestroyed()
m_using_hardware_renderer = false;
}
static std::array<retro_core_option_definition, 49> s_option_definitions = {{
static std::array<retro_core_option_definition, 51> s_option_definitions = {{
{"duckstation_Console.Region",
"Console Region",
"Determines which region/hardware to emulate. Auto-Detect will use the region of the disc inserted.",
@ -684,6 +684,12 @@ static std::array<retro_core_option_definition, 49> s_option_definitions = {{
"Requires geometry correction enabled.",
{{"true", "Enabled"}, {"false", "Disabled"}},
"true"},
{"duckstation_GPU.PGXPDepthBuffer",
"PGXP Depth Buffer",
"Attempts to reduce polygon Z-fighting by testing pixels against the depth values from PGXP. Low compatibility, "
"but can work well in some games. Requires geometry correction enabled.",
{{"true", "Enabled"}, {"false", "Disabled"}},
"false"},
{"duckstation_GPU.PGXPVertexCache",
"PGXP Vertex Cache",
"Uses screen coordinates as a fallback when tracking vertices through memory fails. May improve PGXP compatibility.",
@ -864,6 +870,11 @@ static std::array<retro_core_option_definition, 49> s_option_definitions = {{
{"19", "19"}, {"20", "20"}, {"21", "21"}, {"22", "22"}, {"23", "23"}, {"24", "24"}, {"25", "25"},
{"26", "26"}, {"27", "27"}, {"28", "28"}, {"29", "29"}, {"30", "30"}},
"0"},
{"duckstation_GPU.PGXPPreserveProjFP",
"PGXP Preserve Projection Precision",
"Enables additional precision for PGXP. May improve visuals in some games but break others.",
{{"true", "Enabled"}, {"false", "Disabled"}},
"false"},
{"duckstation_GPU.PGXPTolerance",
"PGXP Geometry Tolerance",
"Ignores precise positions if the difference exceeds this threshold.",

View file

@ -151,6 +151,8 @@ AdvancedSettingsWidget::AdvancedSettingsWidget(QtHostInterface* host_interface,
"PGXPPreserveProjFP", false);
addFloatRangeTweakOption(m_host_interface, m_ui.tweakOptionTable, tr("PGXP Geometry Tolerance"), "GPU",
"PGXPTolerance", -1.0f, 10.0f, 0.5f, -1.0f);
addFloatRangeTweakOption(m_host_interface, m_ui.tweakOptionTable, tr("PGXP Depth Clear Threshold"), "GPU",
"PGXPDepthClearThreshold", 0.0f, 4096.0f, 1.0f, Settings::DEFAULT_GPU_PGXP_DEPTH_THRESHOLD);
addBooleanTweakOption(m_host_interface, m_ui.tweakOptionTable, tr("Enable Recompiler Memory Exceptions"), "CPU",
"RecompilerMemoryExceptions", false);
@ -189,17 +191,18 @@ void AdvancedSettingsWidget::onResetToDefaultClicked()
setBooleanTweakOption(m_ui.tweakOptionTable, 1, false);
setBooleanTweakOption(m_ui.tweakOptionTable, 2, false);
setFloatRangeTweakOption(m_ui.tweakOptionTable, 3, -1.0f);
setBooleanTweakOption(m_ui.tweakOptionTable, 4, false);
setChoiceTweakOption(m_ui.tweakOptionTable, 5, Settings::DEFAULT_CPU_FASTMEM_MODE);
setBooleanTweakOption(m_ui.tweakOptionTable, 6, false);
setIntRangeTweakOption(m_ui.tweakOptionTable, 7, static_cast<int>(Settings::DEFAULT_DMA_MAX_SLICE_TICKS));
setIntRangeTweakOption(m_ui.tweakOptionTable, 8, static_cast<int>(Settings::DEFAULT_DMA_HALT_TICKS));
setIntRangeTweakOption(m_ui.tweakOptionTable, 9, static_cast<int>(Settings::DEFAULT_GPU_FIFO_SIZE));
setIntRangeTweakOption(m_ui.tweakOptionTable, 10, static_cast<int>(Settings::DEFAULT_GPU_MAX_RUN_AHEAD));
setBooleanTweakOption(m_ui.tweakOptionTable, 11, false);
setIntRangeTweakOption(m_ui.tweakOptionTable, 12, 0);
setBooleanTweakOption(m_ui.tweakOptionTable, 13, true);
setFloatRangeTweakOption(m_ui.tweakOptionTable, 4, Settings::DEFAULT_GPU_PGXP_DEPTH_THRESHOLD);
setBooleanTweakOption(m_ui.tweakOptionTable, 5, false);
setChoiceTweakOption(m_ui.tweakOptionTable, 6, Settings::DEFAULT_CPU_FASTMEM_MODE);
setBooleanTweakOption(m_ui.tweakOptionTable, 7, false);
setIntRangeTweakOption(m_ui.tweakOptionTable, 8, static_cast<int>(Settings::DEFAULT_DMA_MAX_SLICE_TICKS));
setIntRangeTweakOption(m_ui.tweakOptionTable, 9, static_cast<int>(Settings::DEFAULT_DMA_HALT_TICKS));
setIntRangeTweakOption(m_ui.tweakOptionTable, 10, static_cast<int>(Settings::DEFAULT_GPU_FIFO_SIZE));
setIntRangeTweakOption(m_ui.tweakOptionTable, 11, static_cast<int>(Settings::DEFAULT_GPU_MAX_RUN_AHEAD));
setBooleanTweakOption(m_ui.tweakOptionTable, 12, false);
setIntRangeTweakOption(m_ui.tweakOptionTable, 13, 0);
setBooleanTweakOption(m_ui.tweakOptionTable, 14, true);
#ifdef WIN32
setBooleanTweakOption(m_ui.tweakOptionTable, 14, false);
setBooleanTweakOption(m_ui.tweakOptionTable, 15, false);
#endif
}

View file

@ -29,6 +29,7 @@ EnhancementSettingsWidget::EnhancementSettingsWidget(QtHostInterface* host_inter
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.pgxpCulling, "GPU", "PGXPCulling", true);
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.pgxpTextureCorrection, "GPU",
"PGXPTextureCorrection", true);
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.pgxpDepthBuffer, "GPU", "PGXPDepthBuffer", true);
connect(m_ui.resolutionScale, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&EnhancementSettingsWidget::updateScaledDitheringEnabled);
@ -101,6 +102,10 @@ EnhancementSettingsWidget::EnhancementSettingsWidget(QtHostInterface* host_inter
dialog->registerWidgetHelp(m_ui.pgxpTextureCorrection, tr("Texture Correction"), tr("Checked"),
tr("Uses perspective-correct interpolation for texture coordinates and colors, "
"straightening out warped textures. Requires geometry correction enabled."));
dialog->registerWidgetHelp(
m_ui.pgxpTextureCorrection, tr("Depth Buffer"), tr("Unchecked"),
tr("Attempts to reduce polygon Z-fighting by testing pixels against the depth values from PGXP. Low compatibility, "
"but can work well in some games. Other games may need a threshold adjustment."));
}
EnhancementSettingsWidget::~EnhancementSettingsWidget() = default;
@ -137,6 +142,7 @@ void EnhancementSettingsWidget::updatePGXPSettingsEnabled()
const bool enabled = m_ui.pgxpEnable->isChecked();
m_ui.pgxpCulling->setEnabled(enabled);
m_ui.pgxpTextureCorrection->setEnabled(enabled);
m_ui.pgxpDepthBuffer->setEnabled(enabled);
}
void EnhancementSettingsWidget::msaaModeChanged(int index)

View file

@ -128,28 +128,35 @@
<property name="title">
<string>PGXP (Precision Geometry Transform Pipeline)</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="pgxpEnable">
<property name="text">
<string>Geometry Correction</string>
</property>
</widget>
</item>
<item>
<item row="0" column="1">
<widget class="QCheckBox" name="pgxpCulling">
<property name="text">
<string>Culling Correction</string>
</property>
</widget>
</item>
<item>
<item row="1" column="0">
<widget class="QCheckBox" name="pgxpTextureCorrection">
<property name="text">
<string>Texture Correction</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="pgxpDepthBuffer">
<property name="text">
<string>Depth Buffer</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View file

@ -325,6 +325,11 @@ void GamePropertiesDialog::populateGameSettings()
QSignalBlocker sb(m_ui.gpuPGXPTolerance);
m_ui.gpuPGXPTolerance->setValue(static_cast<double>(gs.gpu_pgxp_tolerance.value()));
}
if (gs.gpu_pgxp_depth_threshold.has_value())
{
QSignalBlocker sb(m_ui.gpuPGXPDepthThreshold);
m_ui.gpuPGXPDepthThreshold->setValue(static_cast<double>(gs.gpu_pgxp_depth_threshold.value()));
}
if (gs.display_crop_mode.has_value())
{
@ -383,6 +388,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.userPGXPDepthBuffer, gs.gpu_pgxp_depth_buffer);
if (gs.controller_1_type.has_value())
{
@ -561,6 +567,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.userPGXPDepthBuffer, &m_game_settings.gpu_pgxp_depth_buffer);
connect(m_ui.userControllerType1, QOverload<int>::of(&QComboBox::currentIndexChanged), [this](int index) {
if (index <= 0)
@ -704,6 +711,13 @@ void GamePropertiesDialog::connectUi()
m_game_settings.gpu_pgxp_tolerance = static_cast<float>(value);
saveGameSettings();
});
connect(m_ui.gpuPGXPDepthThreshold, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [this](double value) {
if (value <= 0.0)
m_game_settings.gpu_pgxp_depth_threshold.reset();
else
m_game_settings.gpu_pgxp_depth_threshold = static_cast<float>(value);
saveGameSettings();
});
}
void GamePropertiesDialog::updateCPUClockSpeedLabel()

View file

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>750</width>
<height>548</height>
<height>567</height>
</rect>
</property>
<property name="windowTitle">
@ -346,16 +346,6 @@
</item>
<item row="3" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="userTrueColor">
<property name="text">
<string>True Color Rendering (24-bit, disables dithering)</string>
</property>
<property name="tristate">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="userScaledDithering">
<property name="text">
@ -366,26 +356,6 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="userWidescreenHack">
<property name="text">
<string>Widescreen Hack</string>
</property>
<property name="tristate">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="userForceNTSCTimings">
<property name="text">
<string>Force NTSC Timings (60hz-on-PAL)</string>
</property>
<property name="tristate">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="userForce43For24Bit">
<property name="text">
@ -396,6 +366,26 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="userForceNTSCTimings">
<property name="text">
<string>Force NTSC Timings (60hz-on-PAL)</string>
</property>
<property name="tristate">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="userTrueColor">
<property name="text">
<string>True Color Rendering (24-bit, disables dithering)</string>
</property>
<property name="tristate">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="userPGXP">
<property name="text">
@ -406,6 +396,26 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="userWidescreenHack">
<property name="text">
<string>Widescreen Hack</string>
</property>
<property name="tristate">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="userPGXPDepthBuffer">
<property name="text">
<string>PGXP Depth Buffer</string>
</property>
<property name="tristate">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
@ -798,16 +808,30 @@
<item row="6" column="1">
<widget class="QDoubleSpinBox" name="gpuPGXPTolerance">
<property name="minimum">
<number>-1</number>
<double>-1.000000000000000</double>
</property>
<property name="maximum">
<number>10</number>
<double>10.000000000000000</double>
</property>
<property name="singleStep">
<number>0.5</number>
<double>0.000000000000000</double>
</property>
<property name="value">
<number>-1</number>
<double>-1.000000000000000</double>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_30">
<property name="text">
<string>PGXP Depth Threshold:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QDoubleSpinBox" name="gpuPGXPDepthThreshold">
<property name="maximum">
<double>4096.000000000000000</double>
</property>
</widget>
</item>

View file

@ -1042,6 +1042,8 @@ void SDLHostInterface::DrawQuickSettingsMenu()
ImGui::MenuItem("PGXP CPU Instructions", nullptr, &m_settings_copy.gpu_pgxp_cpu, m_settings_copy.gpu_pgxp_enable);
settings_changed |= ImGui::MenuItem("PGXP Preserve Projection Precision", nullptr,
&m_settings_copy.gpu_pgxp_preserve_proj_fp, m_settings_copy.gpu_pgxp_enable);
settings_changed |= ImGui::MenuItem("PGXP Depth Buffer", nullptr, &m_settings_copy.gpu_pgxp_depth_buffer,
m_settings_copy.gpu_pgxp_enable);
ImGui::EndMenu();
}
@ -1603,7 +1605,19 @@ void SDLHostInterface::DrawSettingsWindow()
settings_changed |= ImGui::Checkbox("PGXP Culling", &m_settings_copy.gpu_pgxp_culling);
settings_changed |= ImGui::Checkbox("PGXP Texture Correction", &m_settings_copy.gpu_pgxp_texture_correction);
settings_changed |= ImGui::Checkbox("PGXP Vertex Cache", &m_settings_copy.gpu_pgxp_vertex_cache);
settings_changed |= ImGui::Checkbox("PGXP CPU", &m_settings_copy.gpu_pgxp_cpu);
settings_changed |= ImGui::Checkbox("PGXP CPU Instructions", &m_settings_copy.gpu_pgxp_cpu);
settings_changed |= ImGui::Checkbox("PGXP Preserve Projection Precision", &m_settings_copy.gpu_pgxp_enable);
settings_changed |= ImGui::Checkbox("PGXP Depth Buffer", &m_settings_copy.gpu_pgxp_depth_buffer);
ImGui::Text("PGXP Depth Clear Threshold:");
ImGui::SameLine(indent);
float depth_clear_threshold = m_settings_copy.GetPGXPDepthClearThreshold();
if (ImGui::SliderFloat("##clear_threshold", &depth_clear_threshold, 0.0f, 4096.0f))
{
m_settings_copy.SetPGXPDepthClearThreshold(depth_clear_threshold);
settings_changed = true;
}
}
ImGui::EndTabItem();